我遵循this guide在Linux计算机上设置示例WordPress网站。软件包已更改为较新的php7.2-gd
,php7.2-curl
和libssh2-php
。我的/etc/nginx/sites-available/davewordpress
文件如下:
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;
}
}
在davewordpress
中创建/etc/nginx/sites-enabled
链接并重新启动nginx
和php7.2-fpm
之后,我的localhost
会显示空白页。我做错了什么?
答案 0 :(得分:0)
好吧,我在寻找解决方案时遇到了this link,这确实可以帮助我们指向location ~ \.php$
块。我注释了两行,并使其起作用。现在,该块看起来像这样:
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;
}
第一行使用sudo nginx -t
报告此问题:
"try_files" directive is duplicate in /etc/nginx/snippets/fastcgi-php.conf:5
第二行报告此问题:
"fastcgi_index" directive is duplicate in /etc/nginx/sites-enabled/u1804wordpress:27
很高兴终于弄明白了。我了解第一个错误。但是,有人可以向我解释第二个吗?