首页 > Web开发 > 详细

centos6下nginx配置php可用

时间:2017-06-09 12:25:08      阅读:325      评论:0      收藏:0      [点我收藏+]

先查看下所有服务的状态,看看php-fpm有没有正在运行

[root@centos64 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

[root@centos64 html]# yum --enablerepo=remi install php php-fpm  

安装完成之后再看看服务状态应该就有了,service --status-all,启动php-fpm服务

最后就是修改nginx.conf配置文件了

[root@centos64 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

[root@centos64 html]# /var/nginx/sbin/nginx -s reload

centos6下nginx配置php可用

原文:http://www.cnblogs.com/hltswd/p/6971281.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!