0

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.

4
  • Is /scripts/php located in /budget-calculator?
    – quanta
    Oct 11, 2011 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/. Oct 11, 2011 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, 2011 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. Oct 11, 2011 at 16:53

1 Answer 1

0

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.

2
  • 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? Oct 25, 2011 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. Oct 25, 2011 at 20:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .