NginX with FastCGI and WordPress in a subdirectory – “No input file specified”

I’m trying to migrate a WordPress blog to a subdirectory of my website (i.e. example.com/blog/). Using NginX and FastCGI, I’ve managed to get the entire WordPress site working on port 8080, but as soon as I attempt to apply rules to place it in /blog, I get “No input file specified”

I think because I can get PHP and WordPress working, I can assume that there are no issues with my installation or the permissions of the relevant folders.

Read More

This is what my virtual host looks like (I am running a rails site at “/”):

    server {
    listen       80;
    server_name  example.com localhost;

    #charset koi8-r;

    #access_log  logs/host.access.log  main;

    location /blog/ {
        root /home/deploy/www/blog.example.com/html;
        index index.php;
        try_files $uri $uri/ /blog/index.php;
    }

    location ~ .php$ {
        root /home/deploy/www/blog.example.com/html;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    location / {
        root   /home/deploy/www/example.com/public;
        passenger_enabled on;
        index  index.html index.htm;
    }

I have also tried this configuration for the same result:

    location ~ ^/blog/.*(.php)?$ {
           fastcgi_split_path_info ^(.+.php)(.*)$;
           root   /home/deploy/www/blog.example.com/html;
           try_files $uri =404;
    #        fastcgi_split_path_info ^(/blog/.+.php)(.*)$;

            #fastcgi_split_path_info ^(.+.php)(/.+)$;
            #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini

            include fastcgi_params;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    #       fastcgi_intercept_errors on;
          fastcgi_pass 127.0.0.1:9000;
    }

What am I doing wrong?

Related posts

Leave a Reply

1 comment

  1. Are you using WordPress with Multisite?

    I am not clear about your setup, but a tutorial from this list will surely help you: http://rtcamp.com/wordpress-nginx/tutorial

    If you can share more details, I can guide you better.

    From where does 8080 coming into picture? R u using Nginx with Apache??

    “No input file specified” looks like an error related to incorrect location of PHP file…

    Try changing

    enter code herefastcgi_index index.php;

    to

    try_files index.php blog/index.php
    

    Assuming ‘blog’ is a folder where you moved your WordPress.