1.安裝擴充
yum -y install perl-DBI curl-devel libcurl-level mysql mysql-devel gcc gcc-c++ openssl openssl-devel pcre pcre-devel zlib zlib-devel bzip2 bzip2-devel libxml2 libxml2-devel libmhash libmhash-devel libjpeg libjpeg-devel libpng libpng-devel
2.下載下傳php和php-fpm
wget http://soft.7dot.com/soft/php-5.2.17.tar.gz
wget -c http://php-fpm.org/downloads/php-5.2.17-fpm-0.5.14.diff.gz
3.安裝編譯php
tar zxvf php-5.2.17.tar.gz
gzip -cd php-5.2.17-fpm-0.5.14.diff.gz | patch -d php-5.2.17 -p1
cd php-5.2.17
./configure --prefix=/usr/local/php --enable-fastcgi --enable-zip --enable-fpm --enable-gd-native-ttf --with-config-file-path=/usr/local/php/etc --with-config-file-scan-dir=/usr/local/php/etc/php.d --with-bz2 --with-curl --with-libxml-dir --with-gd --with-jpeg-dir --with-freetype-dir --with-png-dir --with-mcrypt --with-mhash --enable-mbstring --with-kerberos --with-gettext --enable-bcmath --with-mysql --with-mysqli --with-sqlite --enable-pdo --with-pdo-mysql --with-openssl --enable-ftp --with-pear --with-zlib --enable-inline-optimization --enable-calendar --enable-magic-quotes --enable-sockets --enable-sysvsem --enable-sysvshm --enable-sysvmsg --disable-debug
make -j `grep processor /proc/cpuinfo | wc -l`
make test
make install
4.編譯過程可能出錯的地方及改錯方法
1)mcrypt.h not found. Please reinstall libmcrypt
centos源不能安裝libmcrypt-devel,由于版權的原因沒有自帶mcrypt的包,有兩種方法解決,一種是使用第三方源,這樣還可以使用yum來安裝,簡單友善,壞處是第三方源多少有中不可靠的感覺。
解決辦法一
安裝第三方yum源
wget http://www.atomicorp.com/installers/atomic
使用yum指令安裝
yum install php-mcrypt libmcrypt libmcrypt-devel
解決辦法二、
使用php mcrypt 前必須先安裝Libmcrypt
libmcrypt源碼安裝方法:
cd /usr/local/src
wget http://softlayer.dl.sourceforge.net/sourceforge/mcrypt/libmcrypt-2.5.8.tar.gz
tar -zxvf libmcrypt-2.5.8.tar.gz
cd /usr/local/src/libmcrypt-2.5.8
./configure --prefix=/usr/local
make
make install
2)error: Cannot find libmysqlclient under /usr. Note that the MySQL client library is not bundled anymore!
問題是64位系統中 libmysqlclient 預設安裝到了 /usr/lib64/mysql/ 目錄下
而/usr/lib 目錄下沒有相應檔案,但是php編譯時,要去 /usr/lib目錄下查找
解決方法:
ln -s /usr/lib64/mysql/libmysqlclient.so.16.0.0 /usr/lib/libmysqlclient.so
3)/usr/bin/ld: cannot find -lltdl
collect2: ld returned 1 exit status
make: *** [libphp5.la] Error 1
深究該問題應該是該庫的頭檔案庫沒有安裝所緻
yum list all | grep ltdl
yum -y install libtool-ltdl-devel.x86_64
4)
##根據Wrote PEAR system config file at: /usr/local/php/etc/pear.conf
##You may want to add: /usr/local/php/lib/php to your php.ini include_path
##Installing PDO headers: /usr/local/php/include/php/ext/pdo/
##這個資訊,我們需要在目前 php-5.2.17目錄下執行
cp php-5.2.17/php.ini-dist /usr/local/php/lib/php.ini
5)
啟動 PHP-FPM 時,如遇到下面這個錯誤資訊:
Starting php_fpm Feb 07 10:52:35.508786 [ERROR] fpm_unix_conf_wp(), line 124: please specify user and group other than root, pool 'default'
打開 php-fpm.conf 配置檔案,找到下面這個部分:
Unix user of processes
<!-- <value name="user">nobody</value> -->
Unix group of processes
<!-- <value name="group">nobody</value> -->
去掉注釋,并将user和group改為實際實用的使用者群組即可。比如user=nginx group=nginx
5 啟動服務
/usr/local/php/sbin/php-fpm start
service nginx restart