4

I inherited this web server with Nginx and I'm trying to get a new basic PHP site setup on here.

I've followed instructions here. https://gist.github.com/GhazanfarMir/03bd1f1f770a3834d47274586d46ea62

I can read html files just file in my directory. But for PHP files, I see this error in the webpage:

No input file specified.

Not sure how to resolve this. In my conf file I have this configuration for the PHP and root section:

location / {
    root      /var/www/mydomain.org/html;
    index     index.html index.htm index.php;
    try_files $uri/index.html $uri.html $uri @app;
}

location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    include /etc/nginx/fastcgi_params;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_param SCRIPT_FILENAME $request_filename;
}
  • Where is your root statement? – Richard Smith Feb 11 at 22:19
  • above in the file. location / { root /var/www/mydomain.org/html; index index.html index.htm index.php; try_files $uri/index.html $uri.html $uri @app; } – bb2j3z Feb 12 at 16:04
  • What is in the location @app { ... } block? – Richard Smith Feb 12 at 16:10
1

The error message "No input file specified" is almost always because the value of SCRIPT_FILENAME does not point to a file. The location ~ \.php$ needs to know the document root, and the variable $request_filename is constructed by concatenating the document root with the current URI.

You have defined a document root for the location / block, but not the location ~ \.php$ block. Usually, these are the same value, so a single root statement can be placed in the surrounding block, and inherited by all the location blocks that do not override the value.

For example:

root      /var/www/example.org/html;

location / {
    index     index.html index.htm index.php;
    try_files $uri/index.html $uri.html $uri @app;
}

location ~ \.php$ {
    include /etc/nginx/fastcgi_params;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_param SCRIPT_FILENAME $request_filename;
}

location @app {
    ...
}

See this document for details.

  • Thanks this worked... so I can view php files and I got index.php to be the default document. Now I am having problems, trying to make requests with ,php in the address bar. This is what I have.. was looking at some other issues. – bb2j3z Feb 12 at 20:55
  • ` root /var/www/example.org/html; index index.php; try_files $uri $uri/ $uri.html $uri.php$is_args$query_string @extensionless-php; location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; include /etc/nginx/fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } location @extensionless-php { rewrite ^(.*)$ $1.php last; }` – bb2j3z Feb 12 at 20:58
  • Please post this configuration file in a new question, with what you are trying to achieve and where it's going wrong. – Richard Smith Feb 12 at 21:08
  • okay, I figured it out on my own.... thanks. – bb2j3z Feb 13 at 15:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.