centos6下nginx配置php可用
先查看下所有服務的狀態,看看php-fpm有沒有正在運行
[[email protected] html]# service --status-all
php-fpm (pid 3568) 正在運行...
如果php-fpm已停,就開啟此服務:service php-fpm start
如果php-fpm已死或沒有,就先卸載當前的php和httpd,然後再重新安裝php
# yum remove httpd* php*
重新安裝php
默認情況下,CentOS的官方資源是沒有php-fpm的, 但我們可以從Remi的RPM資源中獲得,它依賴於EPEL資源。我們可以這樣增加兩個資源庫:
# yum install yum-priorities -y
# rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-7.noarch.rpm
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
安裝php
[[email protected] html]# yum --enablerepo=remi install php php-fpm
安裝完成之後再看看服務狀態應該就有了,service --status-all,啟動php-fpm服務
最後就是修改nginx.conf配置文件了
[[email protected] html]# vi /var/nginx/conf/nginx.conf
location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /var/nginx/html$fastcgi_script_name; include fastcgi_params; }
找到這段代碼,原先是註釋掉的,打開它,然後把紅色部分修改成項目web根目錄(原先是/scripts)
重啟nginx就可以了,測試ok
[[email protected] html]# /var/nginx/sbin/nginx -s reload
centos6下nginx配置php可用