1.https://lnmp.org/install.html
根据文档新建出环境
2.修改php.ini中
将:
disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,popen,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server
修改为:
disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,popen,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server
修改fastcgi.conf
3.在/usr/local/nginx/conf/vhost/中新建 nginx.conf(更换具体名字)
代码如下:
server {
listen 80;
server_name php69.effortcheep.asia;
root /home/wwwroot/project/laravel-arvin/public;
index index.php index.html;
#access_log /var/log/nginx/www.local.com.log;
error_log /usr/local/nginx/logs/error.log error;
location / {
root /home/wwwroot;
index index.php index.html;
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
if ($request_method = 'OPTIONS') {
return 204;
}
# If file not found, redirect to Zend handling, we can remove the (if) here and go directly rewrite
if (!-e $request_filename){
rewrite ^/(.*) /index.php last;
}
}
location /index.html {
rewrite ^ /index.html break;
}
#limit_conn crawler 20;
location ~* ^.+\.(js|ico|gif|jpg|jpeg|pdf|png|css)$ {
access_log off; #日志关闭
expires 7d; #缓存7天
}
location ~ .*\.(php|php5)?$ {
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param APPLICATION_ENV development;
include fastcgi_params;
#error_page 404 http://audit.local/error;
}
}
4.修改php-fpm:
5(如需要将域名直接匹配到项目下需要做以下操作)
更改nginx.conf配置(新增)
root /home/wwwroot/project/laravel-arvin/public;
location / {
# If file not found, redirect to Zend handling, we can remove the (if) here and go directly rewrite
if (!-e $request_filename){
rewrite ^/(.*) /index.php last;
}
}
location ~ .*.(php|php5)?document_root$fastcgi_script_name;
fastcgi_param APPLICATION_ENV development;
include fastcgi_params;
#error_page 404 http://audit.local/error;
}