问题场景:
nginx经过了简单的配置,开始试验是否可以支持php
location / { root html; index index.htm index.php; } 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; }
在浏览器访问 localhost/index.php
结果为 file not found.
这时候我们查看nginx的错误日志,错误日志的主要内容为 fastcgi sent in stderr: "primary script unknown"
经过分析+搜索前辈经验得出结论,nginx的配置文件无法识别/scripts
路径,所以我们将配置文件中的/scripts
改为$document_root
,或者web目录的绝对路径。更改后的配置文件如下:
location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param script_filename $document_root$fastcgi_script_name; include fastcgi_params; }
重启nginx服务器,已经可以正确显示phpinfo()
的内容了。
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流。
如对本文有疑问, 点击进行留言回复!!
利用UltraScale和UltraScale+FPGA和MPSOC加速DSP设计生产力
【HDFS篇14】HA高可用 --- Federation架构设
gitea宝塔插件 GiteaForBt 宝塔git社区服务器插件比gitlab更轻量的gitea插件
网友评论