当php位于根文件夹中时:
fastcgi_param SCRIPT_FILENAME $fastcgi_script_name
当php位于webroot文件夹中时:
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name
echo $ document_root(显示/ data / www)和$ fastcgi_script_name(显示/echo.php),它们只是webroot文件夹路径和我的请求php路径
整个conf文件:
user ftp1 ftp1;
worker_processes 1;
pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
include vhosts/*.conf;
}
server{
listen 80;
server_name wx.com;
root /data/www/wx120;
index index.html;
location ~ \.php$ {
root /data/www/wx120;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
}
error_log /data/www/wx120/hengerch.error.log;
}