centos 安装 nginx +PHP+FastCGI

Centos6.0

yum install php
php -i | grep cgi
有--enable-fastcgi --enable-force-cgi-redirect选项,安装的是php fastcgi版本
按照wiki.nginx上的说明添加yum repo
/etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1


yum install nginx

修改/etc/php.ini
cgi.fix_pathinfo=1
重启php-gi,经测试发现对普通的应用无明显影响
注:修改php.ini要重启php-cgi

修改nginx.conf
fastcgi_intercept_errors on;
这个参数对处理错误的php脚本有影响,如果php脚本有错误,该参数为off,访问一个错误的php,返回"HTTP/1.1 500 Internal Server Error" 直接管连接,如果是on,还返回一个不可用的提示

fastcgi_param  SCRIPT_FILENAME  <your-php-script-director>$fastcgi_script_name;

该参数关系到nginx能否正确找到php脚本的位置

测试test.php,放在fastcig_parm SCRIPT_FILENAME参数设置的位置
<?php
phpinfo();
?>

curl "http://localhost/test.php"

猜你喜欢

转载自jack-boy.iteye.com/blog/1415905