踩坑记录
为了方便运营推广,我们有一个需求就是用一个域名达到访问两个PHP项目的目的,本来想着这很简单,就是一个代理解决问题,于是便非常潇洒的分分钟配置了一下,如下:
server {
listen 80;
server_name ab.com;
index index.html index.htm index.php index.shtml;
root /a/public;
location /b {
alias /b/public;
index index.html index.htm index.php index.shtml;
}
location ~ [^/]\.php(/|$) {
astcgi_pass unix:/yourpath/to/php-cgi.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
....#这里是一些跟本片文章无关的fastcgi配置
}
}
本以为大功告成,没想到却提示:FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream
一时间找不到头绪了,路径是对的,public下边也存在index.php文件,检查重试了很多遍,无果,便不淡定了,开始了AI大法,但是AI并没有告诉我解决办法,甚至无法理解我的问题,最终在我坚持了半天后,我开始去看了nginx的文档。。。,还是文档