环境:Nginx+PHP7
进入配置文件
$ vim /usr/local/etc/nginx/nginx.conf
找到location / {
和 location ~ \.php$ {
配置如下:
root后面是项目的绝对路径,把root提出来下面👇的location ~ \.php$ {
就可以注释掉root
root /Users/yuanzi/PhpstormProjects/demo_phalcon/public;
location / {
index index.html index.htm index.php;
try_files $uri $uri/ /index.php?_url=$uri&$args;
}
location ~ \.php$ {
# root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
最后重新加载nginx配置:sudo nginx -s reload
Success!~
网友评论