一、下载php tar.gz 包
wget http://cn2.php.net/distributions/php-5.4.40.tar.gz
tar -xvzf php-5.4.40.tar.gz cd php-5.4.40
二 下载相关的组件
wget http://ah1.down.chinaz.com/201303/php-v5.4.13.tar.gz
wget http://soft.7dot.com/soft/libevent-2.0.12-stable.tar.gz wget http://soft.7dot.com/soft/libiconv-1.14.tar.gzwget http://soft.7dot.com/soft/libmcrypt-2.5.8.tar.gz
wget http://soft.7dot.com/soft/mcrypt-2.6.8.tar.gz
wget http://soft.7dot.com/soft/mhash-0.9.9.9.tar.gz
wget http://soft.7dot.com/soft/pcre-8.33.tar.gz
安装依赖软件【软件目录/usr/lcoal/src】 yum -y install gcc yum install -y gcc gcc-c++
tar zxvf pcre-8.33.tar.gz
cd pcre-8.33./configure --prefix=/usr/local
make && make install tar zxvf libiconv-1.14.tar.gz cd libiconv-1.14./configure --prefix=/usr/local
make && make install tar zxvf libmcrypt-2.5.8.tar.gzcd libmcrypt-2.5.8/
./configure
make && make install
/sbin/ldconfig
cd libltdl/
./configure --enable-ltdl-install
make && make install tar zxvf mhash-0.9.9.9.tar.gzcd mhash-0.9.9.9/
./configure
make && make install
cd ../
安装php
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-MySQL=/usr/local/mysql/ --with-mysqli=/usr/local/mysql/bin/mysql_config --with-pdo-mysql=/usr/local/mysql/ --with-fpm-user=www --with-fpm-group=www --with-pcre-regex --with-zlib --with-bz2 --enable-calendar --with-curl --enable-dba --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-zlib-dir --with-freetype-dir --enable-xml --with-pdo-mysql --with-openssl --with-xsl --enable-mbstring --with-mcrypt --with-mhash --enable-fpm
其中会报很多错误 。都是因为缺少相关的组件
make && make install
php-fpm 安装和启动
cp /usr/local/php-5.4.40/etc/php-fpm.conf.default /usr/local/etc/php-fpm.conf cp /usr/local/etc/php-fpm.conf /usr/local/php/etc/php-fpm.conf 查看和编辑 php-fpm.conf 文件vi /usr/local/php/etc/php-fpm.conf
pid = run/php-fpm.pid user = www group = www 新建www 用户组 groupadd www useradd -g www www 启动php-fpm/usr/local/php/sbin/php-fpm
cp /usr/local/src/php-v5.4.13/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm 查看php-fpm 是否启动ps -ef|grep php-fpm
开机启动php
cp /usr/local/php-5.4.40/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm chmod +x /etc/init.d/php-fpm chkconfig --add php-fpm chkconfig --level 2345 php-fpm on