0

Using raspbian stretch, and have configured a site using:

server {
    listen 80 default_server;
    # what does this do? listen [::]:80 default_server;
    root /var/www/html;
    index index.php;
    server_name localhost;
    # First attempt to serve request as file, then as directory, then fall back to displaying a 404.  Maybe change?
    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;
    # Causes too many redirects
    #location / {
    #    index index.php;
    #    try_files  / =404;
    #}
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;

        # With php-fpm (or other unix sockets):
        fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
        # With php-cgi (or other tcp sockets):
        # fastcgi_pass 127.0.0.1:9000;
    }
    # If desired, deny locations: location ~* /(.git|cache|bin|logs|backups|tests)/.*$ { return 403; }
}

The out-of-the-box snippets/fastcgi-php.conf is:

# regex to split $uri to $fastcgi_script_name and $fastcgi_path
fastcgi_split_path_info ^(.+\.php)(/.+)$;

# Check that the PHP script exists before passing it
try_files $fastcgi_script_name =404;

# Bypass the fact that try_files resets $fastcgi_path_info
# see: http://trac.nginx.org/nginx/ticket/321
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;

fastcgi_index index.php;
include fastcgi.conf;

http://10.120.11.40/index.php works but http://10.120.11.40 and http://10.120.11.40/ do not.

Adding fastcgi_split_path_info ^(.+\.php)(/.*)$;, however, allows them to work.

Is the default snippets/fastcgi-php.conf incorrect, or am I doing something wrong?

-1

you can try

index index.php index.htm index.html;
  • Already have index index.php; – user1032531 Nov 23 '17 at 11:57

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.