[nginx php]nginx提示php为未知脚本Primary script unknown的解决办法

时间:2019-05-11  来源:nginx  阅读:

在centos6.4 x86_64上成功编译安装nginx 1.4、php 5.4后,成功启动nginx和php-fpm后,访问php提示错误,同时在错误日志中看到:

Primary script unknown ...

其中nginx配置片段如下:

 代码如下

location ~ .php$ {
    root           /rootToWebFolderPath;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  /rootToWebFolderPath/$fastcgi_script_name;
    include        fastcgi_params;
}

上述配置是正常工作在nginx 1.2、php 5.3下。所以怀疑是其他地方配置有误,一番折腾,问题依旧,再次网上搜索,看到其中一篇文章中提到 fastcgi_param 配置不是使用觉得路径,而是采用了变量($document_root)的方式。尝试修改配置为:

 代码如下 location ~ .php$ {
    root           /rootToWebFolderPath;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    include        fastcgi_params;
}

此时nginx、php正常工作了。注意:上述两处配置中的 fastcgi_param 区别

[nginx php]nginx提示php为未知脚本Primary script unknown的解决办法

http://m.bbyears.com/caozuoxitong/50487.html

推荐访问:
相关阅读 猜你喜欢
本类排行 本类最新