Ubuntu环境下如何将已安装的WordPress接入Nginx?配置求助
问题:WordPress站点PHP文件被下载而非解析(Nginx配置问题)
背景
我在Vultr上部署了搭载WordPress的Ubuntu服务器,此前因问题卸载了Nginx和Certbot,执行命令:
$ sudo apt purge nginx $ sudo apt purge certbot
重装并配置域名SSL后,访问域名显示Nginx欢迎页,/etc/nginx/conf.d目录下仅有default.conf文件。
当前Nginx配置(default.conf)
server { server_name my.domain; #access_log /var/log/nginx/host.access.log main; location / { root /usr/share/nginx/html; index index.html index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} listen 443 ssl; # managed by Certbot ssl_certificate /etc/letsencrypt/live/choice.radio/fullchain.pem; # managed by Certbot ssl_certificate_key /etc/letsencrypt/live/choice.radio/privkey.pem; # managed by Certbot include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot } server { if ($host = my.domain) { return 301 https://$host$request_uri; } # managed by Certbot if ($host = my.domain) { return 301 https://$host$request_uri; } # managed by Certbot listen 80; server_name my.domain; return 404; # managed by Certbot }
尝试的修改及问题
我的WordPress安装在/var/www/html目录,尝试修改location /块为:
location / { root /var/www/html; index index.php; }
但访问域名时PHP文件被直接下载而非解析,其他配置尝试均触发Nginx报错,请求帮助。
内容的提问来源于stack exchange,提问作者David
相关产品推荐
相关产品推荐

