php5源码编译安装,以及一些组件的安装:
a.安装 jpeg7
# tar -zvxf jpegsrc.v7b.tar.gz
# cd jpeg-7b
# ./configure --prefix=/usr/local/jpeg7/ --enable-shared --enable-static
# make; make install
b.安装libpng
# tar -zvxf libpng-1.2.8-config.tar.gz
# cd libpng-1.2.8
# cp scripts/makefile.std makefile
# make; make install
c.安装 freetype
http://sourceforge.net/projects/freetype/files/
# tar -zvxf freetype-2.1.10.tar.gz
# cd freetype-2.1.10
# mkdir -p /usr/local/freetype
# ./configure --prefix=/usr/local/freetype
# make;make install
d.:安装zlib
#tar -zxvf zlib-1.2.3.tar.gz
#cd zlib.1.2.3
# ./configure --prefix=/usr/local/zlib
# make;make install
e.安装GD库
http://download.chinaunix.net/download.php?id=6665&ResourceID=3479
# tar -zvxf gd-2.0.33.tar.gz
# mkdir -p /usr/local/gd2
# cd gd-2.0.33
# ./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg7/
--with-png=/usr/local/lib/
--with-zlib=/usr/local/zlib/
--with-freetype=/usr/local/freetype/
# make; make install
编译过程中如果出现relocation R_X86_64_32 can not be used when making a shared object; recompile with -fPIC,请按照提示找到 CFLAGS 后边加上 -fPIC
f.libmcrypt模块安装
wget http://downloads.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz?r=http%3A%2F
tar zxvf libmcrypt-2.5.8.tar.gz
# cd libmcrypt-2.5.8
# ./configure && make && make install
# cd libltdl
# ./configure --enable-ltdl-install && make && make install
g.安装mhash
#tar -zxvf mhash-0.9.9.9.tar.gz
#cd mhash-0.9.9.9
#./configure
#make
#make install
h.安装mcrypt
#tar -zxvf mcrypt-2.6.8.tar.gz
#cd mcrypt-2.6.8
#LD_LIBRARY_PATH=/usr/local ./configure
#make
#make install
f.安装php
#LIBS='-lresolv' ./configure -prefix=/usr/local/php --with-apxs2=/usr/sbin/apxs --with-mysql=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --without-pear -with-gd=/usr/local/gd2/ --with-jpeg-dir=/usr/local/jpeg7/ --with-zlib-dir=/usr/local/zlib/ --with-png-dir=/usr/local/lib/ --with-freetype-dir=/usr/local/freetype/ --enable-mbstring --with-mcrypt --with-mhash
#make && make install
最后拷贝php源码目录的php.ini-* 到 /etc/php.ini,重启apache
用源码独立编译php的extension库
比如增加mbstring,切换到php源码的ext文件下
cd mbtring
/usr/local/php5/bin/phpize //生成configure编译文件
编译mbstring.so库文件
./configure --with-php-config=/usr/local/php5/bin/php-config --enable-mbstring
make && make install
修改php.ini文件,指定
extension_dir=/usr/local/php5/lib/php/extensions/no-debug-non-zts-20090626/
extension = mbstring.so
重新启动apache
PHP编译支持mysqli
前提是必须安装mysql
直接上命令
先进入源码包我的源码包是在
/usr/local/php-5.2.1/ext/mysqli
这样进入 cd /usr/local/php-5.2.1/ext/mysqli
然后执行
/usr/local/php/bin/phpize
这条命令是生成configure
接下来再执行:
./configure --prefix=/usr/local/php/ext/mysqli --with-php-config=/usr/local/php/bin/php-config --with-mysqli=/usr/local/mysql/bin/mysql_config