1

I'm setting up a new Ubuntu server running nginx, and I'm trying to run a small WordPress blog on the site. I cannot seem to get the configuration for this part right, and I've looked closely at all the docs and online help I could find.

I'm running the blog at www.example.com/blog, and I don't care about any higher location blocks, I just want to get the config right for this one area. I am trying to use:

location /blog/ {
         root /usr/local/www/data;

         try_files $uri $uri/ index.php?$args;
         index index.php;
         location ~ \.php$ {
                  fastcgi_pass 127.0.0.1:9000;
                  fastcgi_index index.php;
                  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                  fastcgi_split_path_info ^(/blog)(/.*)$;
                  include fastcgi_params;
         }
}

I have php-cgi running on 127.0.0.1:9000.

When I try to go to www.example.com/blog, or blog/ or blog/index.php, I get the "No input file specified" error. As a test, I created a phpinfo.php file and put that into /usr/local/www/data/blog/, but that gives the same error.

However, as a further test, I put the phpinfo.php file at /, and then changed the param line to "fastcgi_param SCRIPT_FILENAME /phpinfo.php;", and that did work, so it seems that my FastCGI process is correctly running, but for some reason I'm not getting the path set correctly in nginx.

I've looked closely at the discussion of this issue at http://blog.martinfjordvald.com/2011/01/no-input-file-specified-with-php-and-nginx/, and I have looked at the file permissions, and as far as I can tell, it's all OK. Every directory in the /usr/local/www/data/blog tree has execute permissions, and everything from /usr/local/www on down is owned by, and readable to, the www-data user that runs both nginx and FastCGI.

The logs are not helpful on this; I don't get anything in the error logs even when I set the level to info.

Thanks.

1 Answer 1

2

Remove this from your configuration

fastcgi_split_path_info ^(/blog)(/.*)$;
Sign up to request clarification or add additional context in comments.

6 Comments

No, the root directive appends the /blog/ location to the request; see wiki.nginx.org/HttpCoreModule#root . I had originally had this the other way (which is what Apache-like configs do), but was corrected. Either way, it doesn't make a difference.
Sorry ;(, was just my first thought, I tried it and got it to work if I skip the fastcgi_split_path_info ^(/blog)(/.*)$; otherwise i got Access denied.
It can be something with your fastcgi_params... file
Aha! Yes, removing fastcgi_split_path_info was the trick! I know I didn't even have it in one version, but I must have tried it along with other changes. That, and adding a leading slash before index.php in the try_files line, and everything is working perfectly.
I did not needed the leading slash, mystic... By the way I changed my answer to be correct for future visitors... So please mark it correct ;)
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.