一、安装
安装好PHP环境,这里使用的是lnmp一键安装包。(https://lnmp.org/)
安装前需要注意的是,laravel的环境要求
1. 安装命令可选,blog是项目名称
laravel new blog
composer create-project --prefer-dist laravel/laravel blog
2. 安装完成,配置Nginx,使根目录指到 /public
server
{
listen 8082;
#listen [::]:8082;
server_name laravel.test;
index index.html index.htm index.php default.html default.htm default.php;
root /home/www/laravel/public;
include rewrite/none.conf;
#error_page 404 /404.html;
# Deny access to PHP files in specific directory
#location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }
include enable-php-pathinfo.conf;
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ /.well-known {
allow all;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
}
access_log /home/wwwlogs/laravel.org.log;
}
3. 配置/usr/local/nginx/conf/fastcgi.conf,注释或者删除以下这一行
#fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/";
4. 给予/blog/storage目录读写权限
chmod -R 777 storage
5.打开浏览器访问,可以看到欢迎页