I follow this guide to setup a sample WordPress site on my Linux machine. The packages are changed to the newer php7.2-gd
, php7.2-curl
, and libssh2-php
. My /etc/nginx/sites-available/davewordpress
file is as follow:
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/wordpress;
index index.php index.html index.htm;
server_name localhost;
location / {
#try_files $uri $uri/ =404;
try_files $uri $uri/ /index.php?q=$uri&$args;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~\.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
After creating the davewordpress
link in /etc/nginx/sites-enabled
and restarting nginx
and php7.2-fpm
, my localhost
gives a blank page. What have I done wrong?
OK, I run into this link while searching for the solution, and it really helps by pointing to the location ~ \.php$
block. I comment out two lines and have it working. That blocks now looks like this:
location ~ \.php$ {
#try_files $uri =404;
include snippets/fastcgi-php.conf;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
#fastcgi_index index.php;
include fastcgi_params;
}
Using sudo nginx -t
, the first line reports this problem:
"try_files" directive is duplicate in /etc/nginx/snippets/fastcgi-php.conf:5
The second line reports this problem:
"fastcgi_index" directive is duplicate in /etc/nginx/sites-enabled/u1804wordpress:27
Glad to finally figure it out. I understand the first error. However, can anybody explain to me the second one?