一般情况下安装完nginx后,php的运行目录就在html目录下,但是配置好php访问的时候又提示File not found,实在是匪夷所思,打开nginx.conf配置文件看了下,安装的时候默认的是:
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
这时候就需要修改这行:
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
改为
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
然后再重启nginx就可以运行php了。