linux下php5源码编译安装实践

php5源码编译安装,以及一些组件的安装:

a.安装jpeg7

#tar-zvxfjpegsrc.v7b.tar.gz

#cdjpeg-7b

#./configure--prefix=/usr/local/jpeg7/--enable-shared--enable-static

#make;makeinstall

b.安装libpng

#tar-zvxflibpng-1.2.8-config.tar.gz

#cdlibpng-1.2.8

#cpscripts/makefile.stdmakefile

#make;makeinstall

c.安装freetype

http://sourceforge.net/projects/freetype/files/

#tar-zvxffreetype-2.1.10.tar.gz

#cdfreetype-2.1.10

#mkdir-p/usr/local/freetype

#./configure--prefix=/usr/local/freetype

#make;makeinstall

d.:安装zlib

#tar-zxvfzlib-1.2.3.tar.gz

#cdzlib.1.2.3

#./configure--prefix=/usr/local/zlib

#make;makeinstall

e.安装GD库

http://download.chinaunix.net/download.php?id=6665&ResourceID=3479

#tar-zvxfgd-2.0.33.tar.gz

#mkdir-p/usr/local/gd2

#cdgd-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;makeinstall

编译过程中如果出现relocationR_X86_64_32cannotbeusedwhenmakingasharedobject;recompilewith-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-zxvfmhash-0.9.9.9.tar.gz

#cdmhash-0.9.9.9

#./configure

#make

#makeinstall

h.安装mcrypt

#tar-zxvfmcrypt-2.6.8.tar.gz

#cdmcrypt-2.6.8

#LD_LIBRARY_PATH=/usr/local./configure

#make

#makeinstall

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&&makeinstall

最后拷贝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

相关推荐