今天搭建nginx1.6+php7.3+mysql5.7+wordpress时出现index.php没法解析和403forbidden的问题,html正常解析,最后是修改配置文件默认配置解决现将解决方案写下来以便下次使用:
环境是yum安装的这里不作说明了,直接下载各自最新的repo文件进行安装便可,另外repo文件能够打个包,方便往后使用。更改配置位置以下:php
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,这个一直觉得是权限问题被坑了半天!!!html