本文共 661 字,大约阅读时间需要 2 分钟。
今天搭建nginx1.6+php7.3+mysql5.7+wordpress时出现index.php无法解析和403forbidden的问题,html正常解析,最后是修改配置文件默认配置解决现将解决方案写下来以便下次使用:
环境是yum安装的这里不做说明了,直接下载各自最新的repo文件进行安装即可,另外repo文件可以打个包,方便日后使用。更改配置位置如下:
server {
listen 80;
root /var/www/html/;
location / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php index.php;
}
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
将$document_root加在$fastcgi_script_name前面即可,重启nginx后恢复正常解析php。
注意:需要将/etc/nginx/conf.d/default.conf备份为default.conf.bak,新建wordpress.conf才能打开wordpress否则一直报错404,这个一直以为是权限问题被坑了半天!!!
转载地址:http://ejncl.baihongyu.com/