centos 6.4 安装php-fpm 及常用扩展,(转)

今天又装了一次开发环境,以前忘记记录了

这次记录一下

 

----------------------------------------

centos6 yum安装nginx、php-fpm

1、

使用Nginx官方源,Epel扩展库和remi源,remi源基于epel,必须先安装epel源,remi包含php-fpm,mysql-server5.5,如果只需要php-fpm可以单独安装php-fpm后禁用此源. 
安装 Nginx 源:

rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm

安装EPEL源:

(64位系统) rpm -ivh http://download.fedora.redhat.com/pub/epel/6/x86_64/epel-release-6-5.noarch.rpm
(32位系统) rpm -ivh http://download.fedora.redhat.com/pub/epel/6/i386/epel-release-6-5.noarch.rpm

安装 REMI 源:

rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

开启REMI,编辑 /etc/yum.repos.d/remi.repo

修改 enable=1
yum -y install nginx mysql-server  php-fpm php-cli php-pdo php-mysql php-mcrypt php-mbstring php-gd php-tidy php-xml php-xmlrpc php-pear php-pecl-memcache php-eaccelerator
linux可能会提示没有libmcrypt.so, 解决办法如下:
rpm -ivh http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.i686.rpm
 yum clean all
 yum makecache
yum install libmcrypt
2、设置nginx、php-fpm开机启动:

# chkconfig nginx on
# chkconfig php-fpm on
注:默认安装启动php-fpm时,出现如下错误:

正在启动 php-fpm:[28-Nov-2011 08:11:01] ERROR: [pool www] cannot get uid for user 'apache'
解决办法:

# vi /etc/php-fpm.d/www.conf
找到以下两行:
user = apache
group = apache
将其中的apache都改为nginx。

4、开启80端口(默认是关闭的):
# /sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
# /etc/rc.d/init.d/iptables save
# /etc/init.d/iptables restart
5、修改nginx配置文件,启动nginx和php-fpm:
# vi /etc/nginx/conf.d/default.conf
更改网站的根目录,添加php默认文件:

location / {
root   /usr/share/nginx/html;
index  index.php index.html index.htm;
}
修改到下代码,添加php支持:

# location ~ \.php$ {
#    root      your/web/path;
#    fastcgi_pass   127.0.0.1:9000;
#    fastcgi_index  index.php;
#    fastcgi_param  SCRIPT_FILENAME  /your/web/path$fastcgi_script_name;
#    include        fastcgi_params;
#}
删除上面所有的#和其中一行(root这行),将/your/web/paht修改为web存放目录,如/var/www/html。启动nginx和php-fpm:

# service nginx start
# service php-fpm start
posted @ 2014-04-15 16:28  flex_fly  阅读(555)  评论(0编辑  收藏  举报