[英]Sample PHP page on localhost shows a blank page
我按照本指南在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;
}
}
在/etc/nginx/sites-enabled
创建davewordpress
链接并重新启动nginx
和php7.2-fpm
,我的localhost
给出了一个空白页。 我做错了什么?
好的,我在搜索解决方案时遇到了此链接 ,它指向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
很高兴终于弄明白了。 我了解第一个错误。 但是,有人可以向我解释第二个吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.