5

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;
}
3
  • Where is your root statement? Commented Feb 11, 2019 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
    Commented Feb 12, 2019 at 16:04
  • What is in the location @app { ... } block? Commented Feb 12, 2019 at 16:10

2 Answers 2

3

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.

4
  • 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
    Commented Feb 12, 2019 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
    Commented Feb 12, 2019 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. Commented Feb 12, 2019 at 21:08
  • okay, I figured it out on my own.... thanks.
    – bb2j3z
    Commented Feb 13, 2019 at 15:42
1

I had the same problem.

Check the nginx error.log if you can find a clue as to what it might be.

As I use Windows 11, the problem was the \ in the "root" folder path which caused a GetFileAttributesEx() error.

The solution was to replace it with /.

Maybe your problem is the root folder path, try using another one.

The path uses RegExp, try: /var/www/example\.org/html

0

Your Answer

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

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