我有一个单独的域,其中根由uWSGI下运行的python应用程序提供服务。 然而,我需要在子文件夹/论坛/上运行PHP论坛。 我在apps-availableconfiguration文件中有以下内容:
location / { try_files $uri @oath; } location @oath { include uwsgi_params; uwsgi_pass 127.0.0.1:3031; } location /forum/ { alias /home/drake/forum; index index.php; } location ~ /forum/(.*)\.php { include /etc/nginx/fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass 127.0.0.1:9000; }
然而, example.com/forum/ forum/被发送到uWSGI应用程序和example.com/forum/index.php ,同时被交给FastCGI,返回File not found. 并将以下内容logging到error.log :
2013/03/03 00:10:52 [error] 28102#0: *1 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 93.96.158.230, server: example.com, request: "GET /forum/index.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "example.com"
我究竟做错了什么?
你的/forum/(.*)\/.php块没有设置合适的根目录,所以PHP没有find脚本。 尝试像这样(取代你的论坛位置块):
location /forum { root /home/drake; index index.php; location ~ \.php(?|$) { include /etc/nginx/fastcgi_params; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass 127.0.0.1:9000; } }