Laravel是开源的PHP框架,方便用户开发MVC web应用。
Laravel源代码:https://github.com/laravel/laravel
CentOS 7安装Laravel:
添加两个仓库:
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
安装PHP:
yum install php56w php56w-mysql php56w-mcrypt php56w-dom php56w-mbstring
安装apache和Mariadb:
yum install httpd mariadb mariadb-server
启动Mariadb服务:
systemctl start mariadb
systemctl enable mariadb
启动httpd服务:
systemctl start httpd
systemctl enable httpd
Mariadb数据库root密码默认为空,运行MySQL初始化脚本:
mysql_secure_installation
安装composer:
curl -sS https://getcomposer.org/installer | php
chmod +x composer.phar
mv composer.phar /usr/local/bin/composer
从Github clone Laravel源码:
cd /var/www
git clone https://github.com/laravel/laravel
安装Laravel:
cd laravel
composer install
设置文件权限:
chown -R apache:apache /var/www/laravel
chmod -R 755 /var/www/laravel
创建.env配置文件:
mv .env.example .env
生成App key:
php artisan key:generate
编辑config/app.php,把上面生成的key写入:
配置Apache,创建Virtual Host:
vim /etc/httpd/conf.d/laravel.conf
写入:
<VirtualHost *:80>
DocumentRoot /var/www/laravel/public
ServerName your_domain.com
<Directory /var/www/laravel/>
AllowOverride All
</Directory>
</VirtualHost>
重启Apache服务:
systemctl restart httpd
使用浏览器访问:http://your_domain.com