Nginx – Can’t get PHP to work with the Nginx virtual host. Keeps returning “No input file specified”

nginxPHP

I'm trying to get phpmyadmin up and running on my server. Here's the nginx vhost for it:

server {
    listen 80;
    server_name server.mydomain.net;

    location /phpmyadmin/ {
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /usr/share/phpmyadmin$fastcgi_script_name;

        include /opt/nginx/conf/fastcgi_params;
        alias /usr/share/phpmyadmin/;
    }

    root /opt/nginx/html/;
}

Here's my fastcgi_params file

fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx;
fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;
fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;

I compiled lighthttpd so I could pull out spawn-fcgi. That is now sitting in /usr/local/bin and is accompanied by my php5-cgi launcher which looks like:

#!/bin/sh
/usr/local/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u www-data -C 2 -f /usr/bin/php5-cgi

I run this and can see that it's successfully launched by doing a ps aux | grep php.

However, whenever I try to open phpmyadmin, I get the error "No input file specified"

What am I doing wrong? :/

Best Answer

"No input file specified" is the error PHP gives when it cannot find a file at the path it's given. Nginx passes this path in fastcgi_param SCRIPT_FILENAME /usr/share/phpmyadmin$fastcgi_script_name;

Your error is that $fastcgi_script_name; contains the URI, since you're in location /phpmyadmin/ that means the URI is /phpmyadmin/whatever.php. Therefore you're essentially passing /usr/share/phpmyadmin/phpmyadmin/whatever.php.

If you correct your path it should work.