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都已经安装上了
# 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执行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目录里建一内容为: <?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的页面
------------------------------------------------------