CentOS 7安装LAMP环境及Laravel框架 - 喵了个咪
1、服务器安装源配置
sudo yum install epel-release
sudo rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
sudo yum update
2、SELinux 宽容模式保证安装过程不受影响
sudo setenforce 0
3、Apache, MariaDB, PHP 安装
Laravel 安装程序需要完成安装 LAMP 整个环境,需要额外安装 OpenSSL
、PDO
,Mbstring
和 Tokenizer
等 PHP 扩展。如果 LAMP 已经安装并正常可以正常运行可以跳过这一步。
sudo yum install httpd mariadb-server php56w php56w-mysql php56w-mcrypt php56w-dom php56w-mbstring
Apache、Mariadb 服务开机自动启动
sudo systemctl start httpd
sudo systemctl enable httpd
sudo systemctl start mariadb
sudo systemctl enable mariadb
4、安装Composer
sudo curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
sudo chmod +x /usr/local/bin/composer
5、安装Laravel框架
这里使用默认的apache网站目录/var/www/html
cd /var/www/html
sudo chmod -R 777 /var/www/html
composer create-project laravel/laravel blog 5.1.11
cd blog
sudo chmod -R 777 storage
sudo chmod -R 777 vendor
6、配置虚拟主机
进入Apache虚拟主机目录
cd /etc/httpd/conf.d
新创建一个虚拟主机配置文件,假设现有的域名为blog.com
,为了方便识别,这里创建blog.conf
sudo touch blog.conf
编辑blog.conf
sudo vi blog.conf
参照以下内容输入,邮箱、域名和网站主目录根据自己的情况修改
<VirualHost *:80> ServerAdmin admin@blog.com ServerName blog.com ServerAlias www DocumentRoot /var/www/html/blog/public <Directory "/var/www/html/blog/public"> Options FollowSymLinks AllowOverride All </Directory></VirualHost>
输入完成保存,重启Apache
sudo systemctl restart httpd
浏览器访问你的域名测试!