nginx php Primary script unknown

在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 Primary script unknown

相关文章:

你感兴趣的文章:

标签云: