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

I'm having issues with web.py serving static files. It servers all my javascript/css/images just fine, with no issues, but it's returning a 404 for PHP files. If I visit the php file directly, it gives an 'input file not specified' error.

I do have PHP files configured within the virtual host on nginx, but I'm wondering if I have to do this further down the location tree also? Here is my current nginx configuration for the web.py application:

server {
        listen          80;
        server_name     clearpoint.hyfiv.com;
        error_log       /home/clearpoint/http_error_log;

        location / {
                root    /home/clearpoint;
                index   index.htm index.html index.php;
                }


        location /budget-calculator {
                fastcgi_param           SCRIPT_FILENAME $fastcgi_script_name;
                fastcgi_param           PATH_INFO       $fastcgi_script_name;
                include                 /etc/nginx/fastcgi_params;
                fastcgi_pass            unix:/tmp/cpbc.socket;
        }

        location /budget-calculator/static {
                alias           /home/clearpoint/ClearPoint-Budget-Calc/static;
        }

        location /budget-calculator/static/scripts/php/~\.php$ {
                include /etc/nginx/fastcgi_params;
                fastcgi_pass    unix:/tmp/php.socket;
                fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
        }
}

the test server url for the application being built: http://clearpoint.hyfiv.com/budget-calculator/

Trying to get to the /scripts/php directory returns a 403 forbidden as expected, so the issue I think isn't that it can't find the files, it's that nginx isn't serving them as proper php.

EDIT: I rewrote the entire configuration (changed above). Now getting a 405 error, but that's progress.

EDIT AGAIN: If I manually define thge location of the scripts in the location / block and then manually set the SCRIPT_FILENAME, there are no problems.

I believe I am improperly using the $fastcgi_script_name, but at least I have a workaround while I determine the best course of action given the alias requirements.

share|improve this question
    
Is /scripts/php located in /budget-calculator? –  quanta Oct 11 '11 at 16:41
    
no. budget-calculator is the web.py url. scripts/php is located at /ClearPoint-Budget-Calc/static/scripts/php. It's finding the scripts/js folder for the javascript files with no issue. But that's why I have the alias set up for /budget-calculator/static/. –  Tom Thorogood Oct 11 '11 at 16:45
    
What happens if you request http://clearpoint.hyfiv.com/budget-calculator/static/<any_file>.php? Did you take a look at http_error_log? –  quanta Oct 11 '11 at 16:51
    
I did just notice an error with the inner php directive, but it didn't help. All paths should read /home/ClearPoint-Budget-Calc/static/scripts/php - I checked the error log but there are no entries at all for today. Trying what you suggested: all file names, no matter whether or not exists, return the same "no input file specified" error. –  Tom Thorogood Oct 11 '11 at 16:53

1 Answer 1

up vote 0 down vote accepted

Define SCRIPT_FILENAME in fastcgi_params:

fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;

and change your config file to something like this:

    location /budget-calculator {
        fastcgi_pass unix:/tmp/cpbc.socket;
        include /etc/nginx/fastcgi_params;

        location /budget-calculator/static {
            alias /home/clearpoint/ClearPoint-Budget-Calc/static;

            location ~ ^/budget-calculator/static/scripts/php/\.php$ {
                fastcgi_pass unix:/tmp/php.socket;
            }
        }
    }

Notice that you must use ~ to matches a regular expressions.

share|improve this answer
    
I know this is much later, but I had a server migration so I haven't been able to get back to this. The problem is that $document_root$script_filename can't work, because actual path and $fastcgi_script_name are different, as there is an alias involved. Is there a way to just extract filename.php from $fastcgi_script_name? Then I can set $static_root$actual_filename as the param? –  Tom Thorogood Oct 25 '11 at 14:52
    
I changed the server configuration - if I serve this from its own subdomain, instead of an aliased folder, this problem goes away. –  Tom Thorogood Oct 25 '11 at 20:32

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.