step1:yum install
yum install wget make gcc gcc-c++ bison autoconf patch \ pcre-devel zlib-devel openssl-devel net-snmp-devel \ ncurses-devel libxml2-devel bzip2-devel gd-devel libcurl-devel
以下为ubuntu系统安装包
sudo apt-get install libxml2-dev libssl-dev libbz2-dev libcurl3-dev libdb5.1-dev libjpeg-dev libpng-dev libXpm-dev libfreetype6-dev libt1-dev libgmp3-dev libc-client-dev libldap2-dev libmcrypt-dev libmhash-dev freetds-dev libz-dev libmysqlclient15-dev ncurses-dev libpcre3-dev unixODBC-dev postgresql-server-dev-9.1 libsqlite-dev libaspell-dev libreadline6-dev librecode-dev libsnmp-dev libtidy-dev libxslt-dev libt1-dev
step2:install libmcrypt
wget http://downloads.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz tar zxvf libmcrypt-2.5.8.tar.gz cd libmcrypt-2.5.8 ./configure make make install
step3:download php and patch "fpm"
goto website url: http://www.php.net/get/php-5.2.17.tar.gz/from/a/mirror
use "wget" to download, filename is "php-5.2.17.tar.gz"
tar zxvf php-5.2.17.tar.gz
wget http://php-fpm.org/downloads/php-5.2.17-fpm-0.5.14.diff.gz
gzip -cd php-5.2.17-fpm-0.5.14.diff.gz | patch -d php-5.2.17 -p1
64位系统的CentOS需要执行
cp /usr/lib64/libjpeg.so /usr/lib/ cp /usr/lib64/libpng.so /usr/lib/
step4:install php
cd php-5.2.17
./configure --prefix=/usr/local/php --enable-fastcgi \
--enable-fpm --enable-gd-native-ttf --enable-gd-jis-conv --enable-soap \
--enable-zip --enable-pcntl --enable-sockets --enable-mbstring --enable-xml \
--with-bz2 --with-openssl --with-iconv --with-zlib --with-curl \
--with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-mcrypt \
--with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config
make
make install
ubuntu需要执行
sudo apt-get install libxml2-dev libssl-dev libjpeg-dev libpng12-dev libbz2-dev \
libcurl4-openssl-dev libfreetype6-dev libmcrypt-dev libltdl-dev
cp /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib
cp /usr/lib/x86_64-linux-gnu/libpng.so /usr/lib
执行configura时提示
configure: error: freetype.h not found.
解决方法:
cat configure |grep freetype.h mkdir /usr/include/freetype2/freetype cp /usr/include/freetype2/freetype.h /usr/include/freetype2/freetype/freetype.h
make: *** [ext/dom/node.lo] Error 1
解决方法:
curl -o php-5.2.17.patch https://mail.gnome.org/archives/xml/2012-August/txtbgxGXAvz4N.txt patch -p0 -b <./php-5.2.17.patch
make出现SSL错误提示
php-5.2.17/ext/openssl/xp_ssl.c:357: undefined reference to `SSLv2_server_method'
php-5.2.17/ext/openssl/xp_ssl.c:337: undefined reference to `SSLv2_client_method'
collect2: ld returned 1 exit status
make: *** [sapi/cgi/php-cgi] 错误 1
这个需要一个补丁禁用openssl的SSLv2_client_method,方法如下:
wget http://www.centos.bz/wp-content/uploads/2012/06/debian_patches_disable_SSLv2_for_openssl_1_0_0.patch patch -p1 < debian_patches_disable_SSLv2_for_openssl_1_0_0.patch