在CentOS7上搭建Laravel5.5 PHP7 mariadb apache环境
概述
- 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-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
请访问并确认。
如果能够成功进入Laravel的页面,就代表完成了。