linux下编译安装php5

 安装php支持库,不安装这些支持库也可以,但这些库在平常的开发中都有可能会用到.安装环境CentOS release 4.7 (Final)  2.6.9-78.EL
wget -c ftp://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.11.tar.gz
tar zxvf libiconv-1.11.tar.gz
cd libiconv-1.11
./configure –prefix=/usr/local/libiconv
make
make install
 
wget -c http://download.savannah.gnu.org/releases/freetype/freetype-2.3.7.tar.gz
tar zxvf freetype-2.3.7.tar.gz
cd freetype-2.3.7
./configure
make
make install
 
wget -c ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng-1.2.33.tar.gz
tar zxvf libpng-1.2.33.tar.gz
cd libpng-1.2.33
./configure
make
make install
 
wget -c ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz
tar zxvf jpegsrc.v6b.tar.gz
cd jpegsrc.v6b
./configure –enable-static –enable-shared
mkdir -p /usr/local/man/man1 –如果make的过程中提示不能创建/usr/local/man/man1目录,需要执行这一步
make
make install
make install-lib
 
wget -c ftp://xmlsoft.org/libxml2/libxml2-2.6.30.tar.gz
tar zxvf libxml2-2.6.30.tar.gz
cd libxml2-2.6.30
./configure
make
make install
 
wget -c http://jaist.dl.sourceforge.net/sourceforge/mcrypt/libmcrypt-2.5.8.tar.gz
tar zxvf libmcrypt-2.5.8.tar.gz
ln -s /usr/lib/g++32 /usr/lib/g++      –如果提示找不着C++编译器,执行这不创建一个链接 
./configure
make
make install
/sbin/ldconfig
cd libltdl
./configure –enable-ltdl-install
make
make install
 
wget -c http://jaist.dl.sourceforge.net/sourceforge/mhash/mhash-0.9.9.tar.gz
tar zxvf mhash-0.9.9.tar.gz
cd mhash-0.9.9
./configure
make
make install
 
wget -c http://jaist.dl.sourceforge.net/sourceforge/mcrypt/mcrypt-2.6.7.tar.gz
tar zxvf mcrypt-2.6.7.tar.gz
cd mcrypt-2.6.7
cp /usr/local/lib/libmcrypt*.* /usr/lib
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
./configure
make
make install
 
wget -c http://curl.haxx.se/download/curl-7.19.1.tar.gz
tar zxvf curl-7.19.1.tar.gz
./configure
make
make install
 
wget -c http://www.libgd.org/releases/gd-2.0.35.tar.gz
tar zxvf gd-2.0.35.tar.gz
cd gd-2.0.35.tar.gz
./configure –with-libiconv-prefix –with-png –with-freetype –with-jpeg
make
make install
 
wget -c http://cn.php.net/distributions/php-5.2.6.tar.gz
./configure –prefix=/usr/local/php –with-config-file-path=/etc –enable-fastcgi –enable-force-cgi-redirect –with-libxml-dir –with-zlib –enable-calendar –with-curl –with-curlwrappers –enable-dba=shared –enable-ftp –with-gd –with-jpeg-dir –with-png-dir –with-freetype-dir –enable-gd-native-ttf –enable-mbstring –enable-mbregex –with-mcrypt –with-mhash –with-oci8=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server –with-snmp –enable-sysvsem –enable-sysvshm –with-pear –with-apxs2=/usr/local/apache2/bin/apxs
make
make install
cp /u01/php-5.2.6/php.ini-dist /etc/php.ini
 
这里的php编译支持oracle –with-oci8=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server ,这个路径为ORACLE_HOME,或ORACLE_CLIENT_HOME,如果要编译支持mysql,需要先安装mysql,在php安装中添加 –with-mysql参数.
 
编辑 /etc/php.ini文件,修改include_path路径.
编辑/etc/httpd.conf文件,添加以下内容:
 
LoadModule php5_module        modules/libphp5.so
 
<IfModule dir_module>
    DirectoryIndex index.html index.php index.htm index.phps
</IfModule>
 
PHPIniDir "/etc"
 
AddType application/x-httpd-php .phtml
AddType application/x-httpd-php-source .phps
AddType application/x-httpd-php .php
添加完成后,重新启动apache
apachectl stop
apachectl start
编写一个php脚本测试php的安装情况
vi php_t.php
<?php
phpinfo();
?> 

Relative Posts

Tags:

Reader's Comments »

  1. By tomaer on 2010/05/03 at 11:33 上午

    安装mycrypt的时候出现了问题.能否指导一下呢?

  2. By robinma on 2010/07/23 at 3:02 上午

    @tomaer

    是不是安装顺序的问题啊

Leave a Reply