欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程语言 > php >内容正文

php

[PHP] 安装PHP报错“Primary script unknown”的解决方法

发布时间:2024/9/15 php 70 豆豆
生活随笔 收集整理的这篇文章主要介绍了 [PHP] 安装PHP报错“Primary script unknown”的解决方法 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

当安装完最新版的nginx和最新版的PHP以后,使用niginx默认配置文件中的PHP配置会有错误
访问指定目录下的php文件时,显示File not found.错误。查看nginx的错误日志显示

90#90: *1 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 127.0.0.1, server: 127.0.0.1, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "127.0.0.1"

排查的过程:
1.修改默认PHP配置中的fastcgi_param配置fastcgi_param配置,这个地方默认的是/Scripts$fastcgi_script_name

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

2.把root指令从location /{}块里面拿到外面,因为看fpm的access日志,访问PHP文件报的404错误

最简配置如下:

server {listen 80;server_name 127.0.0.1;access_log /var/log/nginx/default.access.log main;error_log /var/log/nginx/default.error.log;root /var/www/html;location / {index index.html index.htm;}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;} }

 

转载于:https://www.cnblogs.com/taoshihan/p/11602489.html

总结

以上是生活随笔为你收集整理的[PHP] 安装PHP报错“Primary script unknown”的解决方法的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。