3

I have a single domain where the root is served by a python application running under uWSGI. I however need to run a PHP forum on a subfolder /forum/. I have the following in the apps-available configuration file:

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;
}

However, example.com/forum/ is sent to the uWSGI app and example.com/forum/index.php, whilst being handed to FastCGI, returns File not found. and logs the following to 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"

What am I doing wrong?

Drakekin
  • 133
  • 1
  • 3

1 Answers1

4

Your /forum/(.*)\/.php block isn't setting the appropriate root directory, so PHP isn't finding the script. Try something like this (replacing both your forum location blocks):

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;
    }
}
mgorven
  • 30,615
  • 7
  • 79
  • 122