1
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CentOS7でLaravle5.5 PHP7 mariadb apache 環境を構築

Posted at

##概要

  • vagrantのVM等の開発環境構築想定のため、権限、db、apache設定等は最低限です。

##環境

  • CentOS 7
  • apache 2.4
  • mariadb 10.2
  • PHP 7.1
  • Laravel 5.5

##phpインストール

###EPELとRemiリポジトリ追加

sudo yum -y install epel-release
sudo yum -y install http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

###PHP7.1インストール

sudo yum install --enablerepo=remi-php71 php php-cli php-devel php-common php-mbstring php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-gd php-pdo php-xml php-mcrypt  php-fpm php-opcache php-pecl-apcu php-xmlrpc php-intl php-xsl php-soap php-intl php-pecl-zip

###composerインストール

sudo php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
sudo php composer-setup.php

###Composerのコマンド登録

sudo mv composer.phar /usr/local/bin/composer

###Composer composer-setup.php削除

php -r "unlink('composer-setup.php');"

###パスを通す

sudo vi /root/.bash_profile
-----------------------------------
export PATH=$PATH:/usr/local/bin
-----------------------------------
※上記を追記

##Laravelインストール

composer global require "symfony/event-dispatcher"
composer global require "laravel/installer"

###アプリ用フォルダ作成

sudo mkdir -p /var/www/html/laravel
sudo chmod 777 /var/www/html/laravel/

###Laravelプロジェクト作成

composer create-project laravel/laravel /var/www/html/laravel --prefer-dist

###Laravelバージョン確認

cd /var/www/html/laravel
php artisan --version

##Apacheインストール

sudo yum -y install httpd httpd-devel mod_ssl

##コンフィグ設定

sudo vi /etc/httpd/conf.d/vhosts.conf
--------------------------------------------------------
NameVirtualHost *:80

<VirtualHost *:80>
   DocumentRoot /var/www/html/laravel/public
   ServerAdmin webmaster@virtual.host
   ErrorLog logs/laravel-local-error_log
   CustomLog logs/laravel-local-access_log combined

   <Directory "/var/www/html/laravel/public">
       AllowOverride All
       Options MultiViews
       Require all granted

       Options FollowSymLinks
   </Directory>
</VirtualHost>
---------------------------------------------------------
※上記を追記

##起動

sudo httpd -t
※Syntax OKでれば良い

sudo systemctl restart httpd
sudo systemctl enable httpd

##mariaDBインストール

###リポジトリ追加

sudo  vi /etc/yum.repos.d/mariadb.repo
---------------------------------------------------------------------
# MariaDB 10.2 CentOS repository list - created 2017-05-25 08:12 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.2/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
---------------------------------------------------------------------

###mariaDB10.2インストール

sudo yum -y install MariaDB-server MariaDB-client

###設定

cd /etc/my.cnf.d
sudo  cp -p server.cnf server.cnf.original
sudo  sed -i '/^\[mysqld\]$/a character-set-server=utf8' server.cnf
sudo systemctl enable mariadb
sudo systemctl start mariadb

##アクセスして確認
http://127.0.0.1
※Laravelの画面がでれば完了

1
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?