http://www.cnblogs.com/cnsanshao/archive/2012/06/29/2570006.html   待验证

第一步:进入/tmp目录,下载的临时文件将会出现在这里,如果希望长期保存下来,请移动位置,否则第二天这个目录下的文件将会自动清除.

#PHP5.3.8
wget http:
//cn.php.net/distributions/php-5.3.8.tar.bz2

#PHP库文件
wget http:
//ncu.dl.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz
wget http://ncu.dl.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz
wget http://ncu.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz

第二步:安装扩展库文件 (这些文件还是编译的好,yum安装由于版本和位数问题,可能装的不全)

#1
tar
-zxvf libiconv-1.14.tar.gz && cd libiconv-1.14 /
.
/configure --prefix=/usr/local
make
&& make install && cd ../

#
2
tar
-zxvf libmcrypt-2.5.8.tar.gz && cd libmcrypt-2.5.8 /
.
/configure &&  make && make install
/sbin/ldconfig && cd libltdl
./configure --enable-ltdl-
install
make
&& make install && cd http://www.cnblogs.com/

#
3
tar
-zxvf mhash-0.9.9.9.tar.gz && cd mhash-0.9.9.9 /
./configure && make && make install && cd ../


#
4
ln
-s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln
-s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln
-s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln
-s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
ln
-s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
ln
-s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
ln
-s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
ln
-s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
ln
-s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
ln
-s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config

#
5
tar
-zxvf mcrypt-2.6.8.tar.gz && cd mcrypt-2.6.8/
/sbin/
ldconfig
.
/configure
make
&& make install && cd ../

第三步:安装PHP

tar -jxvf php-5.3.8.tar.bz2
cd php
-5.3.8
.
/configure --prefix=/usr/local/webserver/php \
--with-config-file-path=/usr/local/webserver/php/etc \
--with-iconv-dir=/usr/local \
--with-freetype-dir \
--with-mysql=/usr/local/webserver/mysql \
--with-mysqli=/usr/local/webserver/mysql/bin/mysql_config \
--with-jpeg-dir=/usr/lib \
--with-png-dir \
--with-zlib \
--with-mhash --with-mcrypt  \
--enable-sockets \
--enable-ftp \
--with-libxml-dir \
--enable-xml \
--disable-rpath \
--enable-safe-mode \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization --with-curl \
--with-curlwrappers \
--enable-mbregex \
--enable-mbstring \
--with-mcrypt \
--with-gd \
--enable-gd-native-ttf \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-ldap \
--with-ldap-sasl \
--enable-fpm \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--without-pear

编译完后,没问题再继续执行以下脚本

实际上,如果以前没有安装一些应用,单是靠这篇文章,编译出错会出很多

请参照文章《CentOS 5 常见的configure error的解决方法》
make ZEND_EXTRA_LIBS
='-liconv'

#执行完后后出现 make:
*** [ext/phar/phar.php] 错误 127
解决办法:
ln
-s /usr/local/webserver/mysql/lib/libmysqlclient.so.18 /usr/lib/(32位系统)
ln
-s /usr/local/webserver/mysql/lib/libmysqlclient.so.18 /usr/lib64/(64位系统)

执行以上软连接后,再重复上面的
  .
/configure ........
  make ZEND_EXTRA_LIBS
='-liconv'
没问题后再执行
  make install
#选择PHP.ini配置文件
cp php.ini
-production /usr/local/webserver/php/etc/php.ini

#添加WWW用户
/usr/sbin/groupadd www && /usr/sbin/useradd -g www www
mkdir
-p /var/log/nginx && chmod +w /var/log/nginx &&chown -R www:www /var/log/nginx
mkdir
-p /data/www && chmod +w /data/www && chown -R www:www /data/www

cp
/usr/local/webserver/php/etc/php-fpm.conf.default /usr/local/webserver/php/etc/php-fpm.conf
vi
/usr/local/webserver/php/etc/php-fpm.conf
 
#去掉
/更改 配置文件中的;
pm.max_children
= 64
pm.start_servers
= 20
pm.min_spare_servers
= 5
pm.max_spare_servers
= 35
pm.max_requests
= 1024
user
= www
group
= www

#检查语法是否正确
/usr/local/webserver/php/sbin/php-fpm -t
#出现NOTICE: configuration file
/usr/local/webserver/php/etc/php-fpm.conf test is successful 测试成功
/usr/local/webserver/php/sbin/php-fpm &
#设置开机启动
vi
/etc/rc.d/rc.local
#在行末加入
/usr/local/webserver/php/sbin/php-fpm &

至此,php编译安装完成,接下来就得编译安装nginx了。下篇文章将会介绍详细方法。