1.安裝擴展php
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 mysql
2.下載php和php-fpmnginx
wget http://soft.7dot.com/soft/php-5.2.17.tar.gzc++
wget -c http://php-fpm.org/downloads/php-5.2.17-fpm-0.5.14.diff.gzsql
3.安裝編譯phpcentos
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 -p1curl
cd php-5.2.17socket
./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-debugide
make -j `grep processor /proc/cpuinfo | wc -l`php-fpm
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
解決辦法2、
使用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
service mysqld restart
其它的一些細節設置沒有一一詳寫,請你們指教改正!