Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

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;
    }
}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.