Mobile app version of vmapp.org
Login or Join
Martha676

: Nginx to default to index.php Using raspbian stretch, and have configured a site using: server { listen 80 default_server; # what does this do? listen [::]:80 default_server;

@Martha676

Posted in: #Nginx

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: 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;

10.120.11.40/index.php works but 10.120.11.40 and 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?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Martha676

1 Comments

Sorted by latest first Latest Oldest Best

 

@Tiffany637

you can try

index index.php index.htm index.html;

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme