nginx 虚拟目录 php环境

虚拟目录这样就行了,顺利地话.
location /dd/ {
root /chroot/dd;
rewrite /huodong/(.*) /$1 break;
index index.html index.htm index.php;
}

location ~ /dd.+.php$ {
root /chroot/dd;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
rewrite /dd/(.*\.php?) /$1 break;
}

php出现异常
FastCGI sent in stderr: “Primary script unknown” while reading response header from upstream
原因可能是顺序问题
location ~ \.php$ {
….
}
有这样的配置放新加php配置的后面。否则无法生效。php会报404。

发表评论