centos5.9 64x 编译安装php5.2.17
安装wget服务
yum install wget
1.安装Apache
yum install httpd httpd-devel
2.下载tar.gz文件
wget http://museum.php.net/php5/php-5.2.17.tar.gz
wget http://downloads.zend.com/optimi ... ibc23-x86_64.tar.gz
wget http://softlayer.dl.sourceforge. ... mcrypt-2.5.8.tar.gz
3.安装过程需要的组件(如果不先安装,编译的时候会报错)
yum install libxml2 libxml2-devel gcc gcc-c++ libpng libpng-devel libtool libtool-ltdl-devel
64位系统需要对一些模块做软连接,否则会找不到文件
ln -s /usr/lib64/libjpeg.so /usr/lib/
4.安装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
5.安装GD以下为安装包下载地址,可能有变动
libipeg – http://www.ijg.org/files/jpegsrc.v9.tar.gz
libpng – http://t.cn/zTgAx90
zlib – http://t.cn/zTVy3yu
freetype – http://t.cn/zTVyddP
gd – http://fossies.org/linux/www/gd-2.0.35.tar.gz
安装jpeg库
tar zxvf jpegsrc.v9.tar.gz
cd jpeg-9
./configure --prefix=/usr/local/jpeg
make
make install
安装png库
tar zxvf libpng-1.6.1.tar.gz
cd libpng-1.6.1
./configure --prefix=/usr/local/libpng
make
make install
安装zlib
tar zxvf zlib-1.2.7.tar.gz
cd zlib-1.2.7
./configure --prefix=/usr/local/zlib
make
make install
安装FreeType
tar zxvf freetype-2.4.11.tar.gz
./configure --prefix=/usr/local/freetype
make
make install
安装GD
tar zxvf gd-2.0.35.tar.gz
cd gd-2.0.35
./configure --prefix=/usr/local/gd --with-zlib=/usr/local/zlib/ --with-png=/usr/local/libpng/ --with-jpeg=/usr/local/jpeg/ --with-freetype=/usr/local/freetype/
6.某些程序需要支持freetype,编译前先安装freetype,编译时注意freetype的安装路径。如果是后来添加php安装freetype,重新编译php后可能phpinfo还是看不到freetype的支持,试着先make clean清除掉php原来的配置,再重新进行编译安装
7.编译安装php
./configure --prefix=/usr/local/php5 --with-config-file-path=/etc --with-apxs2=/usr/sbin/apxs --with-mysql --with-mysqli --enable-pdo --with-pdo-mysql --with-gd --with-iconv --with-freetype-dir=/usr/include/freetype2/freetype/ --with-jpeg --with-png --with-zlib --with-libxml --enable-xml --enable-discard-path --enable-magic-quotes --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --enable-ftp --enable-gd-native-ttf --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --with-mime-magic --enable-suhosin --enable-session --with-mcrypt --with-curl)
8.安装zend(文件版本及具体位置视具体情况而定)
解压wget http://downloads.zend.com/optimi ... ibc23-x86_64.tar.gz
将data/5_2_x_comp/ZendOptimizer.so 里的文件拷贝到/usr/local/php5/lib/php/extensions/no-debug-non-zts-20060613/
修改/etc/php.ini
在末尾增加一段
[Zend]
zend_extension="/usr/local/php5/lib/php/extensions/no-debug-non-zts-20060613/ZendOptimizer.so"
配置 httpd.conf 让apache支持PHP:
# vi /usr/local/apache/conf/httpd.conf
找到 AddType application/x-gzip .gz .tgz 在其下添加如下内容
AddType application/x-httpd-php .php (.前面有空格)
AddType application/x-httpd-php-source .phps (.前面有空格)
可能会出现的错误
php环境支持curl的时候, 在编译时出现如下报错
checking for cURL in default path... not found
configure: error: Please reinstall the libcurl distribution -
easy.h should be in /include/curl/
其实就是curl的dev包没有安装, 解决方案:
# yum -y install curl-devel
再重新编译OK。
可能出现的错误
配置报错 configure: error: Cannot find libmysqlclient under /usr
64位系统中 libmysqlclient 默认安装到了 /usr/lib64/mysql/ 目录下,而/usr/lib 目录下没有相应文件,但是php编译时,要去 /usr/lib目录下查找
解决方法:
ln -s /usr/lib64/mysql/libmysqlclient.so.16.0.0 /usr/lib/libmysqlclient.so
启动apache报错“httpd: Could not reliably determine the server's fully qualified domain name, using localhost.locald”
vi /etc/httpd/conf/httpd.conf
加入一句
ServerName localhost:80
如果重新编译PHP后重启Apache出现undefined symbol: sapi_globals,configure之前运行一下make clean即可
评论已关闭