[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

时间: 2024-08-05 02:03:26

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

PHP Primary script unknown 终极解决方法

相信很多配置php环境的都遇到过这个恼人的问题: 浏览器访问php文件,返回来 File not found 查看/var/log/nginx/error.log ,有 “Primary script unknown”,类似如下: 2019/01/03 10:24:02 [error] 11931#11931: *260 FastCGI sent in stderr: "Primary script unknown" while reading response header from

【spring boot+mybatis】注解使用方式(无xml配置)设置自动驼峰明明转换(),IDEA中xxDao报错could not autowire的解决方法

最近使用spring boot+mybatis,使用IntelliJ IDEA开发,记录一些问题的解决方法. 1.在使用@Mapper注解方式代替XXmapper.xml配置文件,使用@Select等注解配置sql语句的情况下,如何配置数据库字段名到JavaBean实体类属性命的自动驼峰命名转换? 使用spring boot后,越来越喜欢用注解方式进行配置,代替xml配置文件方式.mybatis中也可以完全使用注解,避免使用xml方式配置mapper.(参考  springboot(六):如何优

mysql登录报错ERROR 1045 (28000的解决方法

问题描述: mysql -u root -p命令登录MySQL,提示ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) 解决办法: information_schema 库的USER_PRIVILEGES 表中 没有给 'root'@'localhost' 赋权. mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' ID

Github上LeakCanary编译报错CreateProcess error=2的解决方法

现象说明: 从github上拉下LeakCanary编译时报错 1 CreateProcess error=2, ??Õ?»µ½?¶ 原因分析: 该现象是由于Windows中Gradle调用命令未加cmd.exe /C导致Windows无法识别命令 解决方案: 定位到报错的gradle代码为leakcanary-android模块的build.gradle中的gitSha()方法,修改代码为: 1 def gitSha() { 2 return 'cmd.exe /C git rev-parse

Android NDK报错(Eclipse)及解决方法

在AndroidNDK开发过程中,工程目录下的jni文件夹下编写的c/c++代码,通常会出现如下的几种类型的报错: 1.Unresolved inclusion:<XXX> 2.syntax error 3.Function 'XXX' could not be resolved 4.Type 'XXX' could not be resolved 5.Symbol 'XXX' could not be resolved 6.Method 'XXX' could not be resolved

Arcgis Javascript中geometryEngine报错’hq‘of undefined的解决方法

这个问题困扰了我一个星期,原因是使用geomagicbuffer时候,有的线可正常使用,有的就直接报错,一直没有解决,后来发现是api自己的bug导致的 干脆直接读代码,在geometryEngine第737行,有这么一句话(不同版本的额api可能会不同): if((this.Ec||1E4<u.jq&&1<u.Ci.length)......... 报错的就是这里,因为u没有判断是否存在,导致执行u.jq时候报错 按照下面修改就好啦 if((u)&&(u.jq

mac安装sudo pip install MySQL-python报错EnvironmentError: mysql_config not found解决方法

PATH="/usr/local/mysql/bin:${PATH}" export PATH export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/ export VERSIONER_PYTHON_PREFER_64_BIT=no export VERSIONER_PYTHON_PREFER_32_BIT=yes 参考文档:http://www.cnblogs.com/ifantastic/archive/2013/04/13/3017677.h

pdo 连接数据库 报错 could not find driver 解决方法

在windows 下,调试一个PHP程序时,报了这个错误, could not find driver 原来我的这个程序中用到了PDO对象, 连接mysql 5.  在PHP的默认设置中,只打开了php_pdo 模块, 没有打开php_pdo_mysql模块.所以才会出现找不到驱动程序的错误. 把这个模块打开,重启apache就可以了. 当然了,如果你用别的数据库,打开对应的模块就OK了. extension=php_pdo_mysql

Hadoop中RPC协议小例子报错java.lang.reflect.UndeclaredThrowableException解决方法

最近在学习传智播客吴超老师的Hadoop视频,里面他在讲解RPC通信原理的过程中给了一个RPC的小例子,但是自己编写的过程中遇到一个小错误,整理如下: log4j:WARN No appenders could be found for logger (org.apache.hadoop.metrics2.lib.MutableMetricsFactory).log4j:WARN Please initialize the log4j system properly.log4j:WARN See