1. 安裝zlib (安裝libpng和gd前需要先安裝zlib),
    # tar zxvf zlib-1.2.3.tar.gz
    # cd zlib-1.2.3
    # ./configure
    # make;make install   
2. 安裝libpng,
    # tar zxvf libpng-1.2.12.tar.gz
    # cd libpng-1.2.12
    # ./configure
    # make;make install   
3. 安裝freetype,
    # tar zxvf freetype-2.2.1.tar.gz
    # cd freetype-2.1.10
    # ./configure --prefix=/usr/local/freetype
    # make;make install   
4. 安裝jpeg,
    # tar zxvf jpegsrc.v6b.tar.gz
    # cd jpeg-6b
    # mkdir /usr/local/jpeg
    # mkdir /usr/local/jpeg/bin
    # mkdir /usr/local/jpeg/lib
    # mkdir /usr/local/jpeg/include
    # mkdir /usr/local/jpeg/man
    # mkdir /usr/local/jpeg/man/man1
    # ./configure --prefix=/usr/local/jpeg --enable-shared --enable-static
    # make;make install   
5. 安裝gd,
    # tar zxvf gd-2.0.35.tar.gz
    # cd gd-2.0.35
    # ./configure --prefix=/usr/local/gd --with-jpeg=/usr/local/jpeg --with-freetype=/usr/local/freetype --with-png --with-zlib
    //編譯過程中會看到如下信息
    ** Configuration summary for gd 2.0.33:    Support for PNG library: yes
    Support for JPEG library: yes
    Support for Freetype 2.x library: yes
    Support for Fontconfig library: no
    Support for Xpm library: no
    Support for pthreads: yes
    //可以看到png 、 jpeg 、 freetype都已經(jīng)安裝上了
    # make
    # make install   
6. 正式安裝php
    # tar zxvf php-5.2.3.tar.gz
    # cd php-5.2.3
    #  ./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/lib/mysql --with-gd=/usr/local/gd --with-zlib-dir  --with-jpeg-dir=/usr/local/jpeg --with-freetype-dir=/usr/local/freetype --enable-sockets --with-iconv --enable-mbstring --enable-force-cgi-redirect --with-config-file-path=/usr/local/php5/etc
    # make
    # make install   

7.整合php和apache
    cp php.ini-dist /usr/local/php5/etc/php.ini
    vi /usr/local/php5/etc/php.ini
    將extension=php_mysql.dll前面的;去掉
    注意在/usr/local/apache2/conf/httpd.conf加上下代碼使apache執(zhí)行PHP 
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php3 .php3
    AddType application/x-httpd-php4 .php4
    AddType application/x-httpd-php-source .phps   

8. 安裝ZendOptimizer
    # tar zxvf ZendOptimizer-3.0.1-linux-glibc21-i386.tar.gz
    # cd ZendOptimizer-3.0.1-linux-glibc21-i386
    # ./install.sh    附:軟件下載地址:    apache 2.2.4 http://www.jtcyxx.com/down/2007/1030/down_5.html
   mysql 5.0.22: http://download.jcwcn.com/soft/server/2007-02-14/75.html#edown
   php 5.2.9: http://www.php.net/downloads.php#
   zlib 1.2.3: http://www.zlib.net/zlib-1.2.3.tar.gz   libpng 1.2.23:http://jaist.dl.sourceforge.net/sourceforge/libpng/libpng-1.2.23.tar.gz   freetype 2.3.5:http://nchc.dl.sourceforge.net/sourceforge/freetype/freetype-2.3.5.tar.gz   jpeg: http://www.ijg.org/files/jpegsrc.v6b.tar.gz
    gd 2.0.35: http://www.libgd.org/releases/gd-2.0.35.tar.gz

 

===================================

重啟apache
# /usr/local/apache2/bin/apachectl restart
在/usr/local/apache2/htdocs目錄里建一內(nèi)容為: <?php phpinfo(); ?> 的PHP文件,命名為index.php, 輸入URL地址:http://localhost/index.php,查看PHP配置是否正確

如果不正確,可以重啟機子在試

------------------------------------------------------
自定義文件目錄,修改http.conf
ServerName http://localhost:80

DocumentRoot /var/www

#<Directory "/usr/local/apache2/htdocs">
<Directory "var/www">
(注意不要和perl的配置沖突)

如果增加歡迎頁面則:
<IfModule dir_module>
    DirectoryIndex index.html index.php
</IfModule>
這樣只要輸入http://localhost/即可得到index.php的頁面

------------------------------------------------------