1、安装
[root@localhost php-5.3.20]#  ./configure \
--prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--with-mysql \
--with-mysql=/usr/local/mysql/ \
--with-mysqli \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-pdo-mysql \
--with-pdo-mysql=/usr/local/mysql \
--with-iconv-dir \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir \
--disable-rpath \
--enable-xml \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--with-curl \
--with-curlwrappers \
--enable-mbregex \
--enable-fpm \
--enable-mbstring \
--with-mcrypt \
--with-gd \
--enable-gd-native-ttf \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--enable-intl=shared \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--with-pear \
--enable-pdo \
--with-gettext \
--enable-exif \
--enable-wddx \
--enable-calendar \
--enable-ftp \
--enable-dba \
--enable-sysvmsg \
--enable-sysvshm \
--enable-debug \
--enable-maintainer-zts \
--enable-embed=fpm \
--with-pcre-regex \
--enable-gd-jis-conv \
--with-bz2 \
--with-xsl \
--with-t1lib \
--with-xpm-dir \
--mandir=/usr/local/share/man \
--infodir=/usr/local/share/info

[root@localhost php-5.3.20]#  
  make && make install 

 #复制源码安装文件夹的phpfpm启动到系统init.d目录下
[root@localhost php-5.   3.20   ]# cp   ./sapi/fpm/init.d.php-fpm   /etc/init.d/phpfpmd  
[root@localhost php-5.   3.20   ]# chmod u+x  /etc/init.d/phpfpmd    
[root@localhost php-5.   3.20   ]# chkconfig phpfpmd on    

 #复制源码安装文件夹的php.ini 到系统安装路径下
[root@localhost php-5. 3.20 ]# cp php.ini-production  /usr/local/php/etc/php.ini
[root@localhost php-5. 3.20 ]# vim  /usr/local/php/etc/php.ini
add: include_path="../php/incluce:/usr/local/php/lib/php"

#配置php-fpm.conf启动参数,以下为一般测试机参数,生产机可适当调整
[root@localhost etc]# grep -v ";" php-fpm.conf | grep -v ^$|grep -v ^\ 
[global]
pid = run/php-fpm.pid
error_log = log/php-fpm.log
syslog.facility = daemon
syslog.ident = php-fpm
log_level = notice
emergency_restart_threshold = 0
emergency_restart_interval = 0
process_control_timeout = 0
daemonize = yes
rlimit_files = 1024
rlimit_core = 0
[www]
user = nobody
group = nobody
listen = 127.0.0.1:9000
listen.allowed_clients = 127.0.0.1
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
pm.max_requests = 500
access.log = /usr/local/php/var/log/$pool.access.log
access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%"
slowlog = log/$pool.log.slow
request_slowlog_timeout = 0
request_terminate_timeout = 0
rlimit_files = 1024
rlimit_core = 0
catch_workers_output = yes
php_admin_value[error_log] = /var/log/fpm-php.www.log
php_admin_flag[log_errors] = on
php_admin_value[memory_limit] = 32M
相关参数中文可参考http://www.cnblogs.com/zoro/archive/2012/01/10/2317964.html 博文
2、排错
出现提示: You've configured multiple SAPIs to be build. You can build only  one SAPI module and CLI binary at the same time.
[root@localhost php-5.3.20]# ./configure  --help | grep embed
--enable-embed[=TYPE]   EXPERIMENTAL: Enable building of embedded SAPI library
在编译参数中指定[TYPE] 为fpm,网上有朋友说在--enable-fpm 与--with-apxs2= 这两个参数中二选一,可是我的编译参数中根本没有 --with-apxs2=  这个参数,后天在configure中打出日志,发现其PHP_ISAP的值为默认的 embed,而我的要求是fpm ,所以修改 --enable-embed=fpm即可,在5.4.6的PHP版本中可以不需要指定。

出现提示:  configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
[root@localhost php-5.3.20]# yum install  libxslt-devel 
有时候可能是系统没有在默认的路径下找到xslt-config这个文件 ,可以用find /  -iname  xslt-config 这个查找 一下系统中有无这个文件 ,如果有则只需要ln -s 做一个该文件 的软链接到系统默认的路径 /usr/bin/ 下就可以了 

出现提示:  /root/php-5.3.20/sapi/cli/php: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
[root@localhost php-5.3.20]# cat /etc/ld.so.conf
include ld.so.conf.d/*.conf
/usr/local/mysql/lib/
[root@localhost php-5.3.20]# ldconfig 
[root@localhost php-5.3.20]#  make clean
[root@localhost php-5.3.20]#    make 
因为系统没有找到mysql的链接库文件,可以先去/usr/local/mysql/lib/ 下查看libmysqlclient.so.18.0.0文件是否存在,如果不存在,则说明你的mysql没有安装成功 。如果有,但没有libmysqlclent.so.18,可以ln -s 做一个软链接

附带以下为安装5.4.6时出现的错误及解决办法
Message: libXpm.(a|so) not find
[root@localhost php-5.4.6]#  ln -s  /usr/lib64/libXpm.so /usr/lib/

exp:configure: error: Your t1lib distribution is not installed correctly. Please reinstall it.
源码安装 t1lib-5.1.2.tar.gz ( tar -zxvf  t1lib-5.1.2.tar.gz && ./configure && make && make install )

Message:configure: error: Unable to detect ICU prefix or no failed. Please verify ICU install prefix and make sure icu-config works.
源码安装 icu4c-49_1_2-src.zip ( unzip   icu4c-49_1_2-src.zip  && ./configure && make && make install )

每个人的系统都不一样,当出现报错时尽量去查日志或是google,我只出现了这两个错误,大概是前面已经安装过相应的支持文件