yum的方式安装软件很方便,编译安装真的是太累了
一个新服务器要搞定所有东西,真是太麻烦
要不然就是安装apache,也很方便
php的很多功能都是模块化安装,比如连json的解析都需要额外安装
系统:centos 5.5
1.安装前准备
yum -y install php-devel php-pear gcc make
2.安装json
pear install pecl/json
或者
pecl install json
3.让php支持json
我的php是yum安装的,所以
cd /etc/php.d
echo “extension=json.so” > json.ini
重启apache
service httpd restart
如果有selinux,执行下面命令
chcon system_u:object_r:textrel_shlib_t /usr/lib/php/modules/json.so
或
chcon -c -v -R -u system_u -r object_r -t textrel_shlib_t /usr/lib/php/modules/json.so
4.验证
php -m|grep json
json
可以看到php已经支持json了,现在可以重新去执行了php页面了
上面来自:http://blog.slogra.com/post-272.html
安装 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
转载请注明:爱开源 » yum方式安装php-fpm