==========================================================================================
(00) Windows安装:
Both PHP 4 and PHP 5 have three mode:
CGI executable,
a CLI executable, --The CLI version is designed to let you use PHP for command line scripting
server modules, --Server modules provide significantly better performance and additional functionality compared to the CGI binary

To make php4ts.dll / php5ts.dll available you have three options:
copy the file to the Windows system directory
copy the file to the web server's directory
add your PHP directory(C:\php) to the PATH
For better maintenance, we advise you to follow the last option, add C:\php
to the PATH, because it will be simpler to upgrade PHP in the future.

以下是apache modules方式安装:
a) 设置 E:\tool\php\php-5.2.6-Win32 到系统 Path
b) 把php.ini-recommended复制一份,命名为:php.ini
c) 编辑apache的httpd.conf,加入:
# For PHP 5 to apache2.2:
LoadModule php5_module "E:/tool/php/php-5.2.6-Win32/php5apache2_2.dll"
AddType application/x-httpd-php .php
# configure the path to php.ini
PHPIniDir "E:/tool/php/php-5.2.6-Win32"
d)然后重启机器(因为windows只有重启Path的设置才能生效)


============================================================================================================
(01)Linux安装:

cd /usr/local
mkdir php5
mkdir modules
cd /root/abiao-disk

安装freetype
tar xzvf freetype-2.1.10.tar.gz
cd freetype-2.1.10
./configure --prefix=/usr/local/modules/freetype
make
make install

安装png
tar xzvf libpng-1.2.5.tar.gz
cd libpng-1.2.5

#不需用configure 自定义安装目录,影响gd的安装
cp scripts/makefile.std makefile
make
make install

安装jpeg
tar xzvf jpegsrc.v6b.tar.gz
cd jpeg-6b
mkdir /usr/local/modules/jpeg6
mkdir /usr/local/modules/jpeg6/bin
mkdir /usr/local/modules/jpeg6/lib
mkdir /usr/local/modules/jpeg6/include
mkdir /usr/local/modules/jpeg6/man
mkdir /usr/local/modules/jpeg6/man/man1
./configure --prefix=/usr/local/modules/jpeg6 --enable-shared --enable-static
make
make install

安装freetds
tar xzvf freetds-0.82.tar.gz
cd freetds-0.82
./configure --prefix=/usr/local/freetds --with-tdsver=8.0
make
make install

安装php (安装php之前,最好确保mysql先安装了,否则后面编译会出错)
cd /root/abiao-disk/php-5.2.7
php必要的选项:
--prefix=/usr/local/php
--with-apxs2=/usr/local/apache/bin/apxs
--with-mysql=/usr/local/mysql/
--with-libxml-dir
--enable-mbstring

这是让PHP支持GD库的配置选项:
--with-gd=/usr/local/gd2/
--with-jpeg-dir=/usr/local/jpeg6/
--with-png
--with-zlib-dir=/usr/lib
--with-freetype-dir=/usr/local/freetype

 

 

只需要数据库支持的话:
./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/apache2/conf

需要图片支持的话:
./configure --prefix=/usr/local/php5 --enable-mbstring --enable-sockets --enable-bcmath --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-freetype-dir=/usr/local/modules/freetype --with-jpeg-dir=/usr/local/modules/jpeg6 --with-png-dir=/usr --with-config-file-path=/usr/local/apache2/conf --with-gd --with-png

需要图片支持并且加上snmp的话:
./configure --prefix=/usr/local/php5 --enable-mbstring --enable-sockets --enable-bcmath --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-freetype-dir=/usr/local/modules/freetype --with-jpeg-dir=/usr/local/modules/jpeg6 --with-png-dir=/usr --with-config-file-path=/usr/local/apache2/conf --with-gd --with-png --with-snmp=/usr

需要图片支持并且加上snmp和mssql支持的话【我们用这个】:
./configure --prefix=/usr/local/php5 --enable-mbstring --enable-sockets --enable-bcmath --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-freetype-dir=/usr/local/modules/freetype --with-jpeg-dir=/usr/local/modules/jpeg6 --with-png-dir=/usr --with-config-file-path=/usr/local/apache2/conf --with-gd --with-png --with-snmp=/usr --with-mssql=/usr/local/freetds

如果出现configure: error: Try adding --with-zlib-dir=<DIR>. Please check config.log for more information.
就修改configure文件,找到:
-l$MYSQL_LIBNAME
替换成:
-l$MYSQL_LIBNAME -lmygcc
再执行configure即可

如果报snmp的错,应该是没有装snmp ,暂时不装这个 ,删掉--with-snmp=/usr

make
make install

##make时报错make: *** [sapi/cli/php] Error 1
解决方法:make ZEND_EXTRA_LIBS='-liconv'

cp php.ini-recommended /usr/local/apache2/conf/php.ini

vi /usr/local/apache2/conf/php.ini
增加以下行,以让mssql数据库查询不出现乱码
mssql.charset = "GBK"

vi /usr/local/apache2/conf/httpd.conf
加入(注意之前加过了就不用再加,否则apache不能启动:
LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php


/usr/local/apache2/bin/apachectl restart
如果碰到:
httpd: Syntax error on line 55 of /usr/local/apache2/conf/httpd.conf: Cannot load /usr/local/apache2/modules/libphp5.so into server: /usr/local/apache2/modules/libphp5.so: cannot restore segment prot after reloc: Permission denied
则需要运行:
chcon -t textrel_shlib_t /usr/local/apache2/modules/*.so
或者干脆关闭SELinux:
vi /etc/selinux/config
把文件中的SELINUX="enforcing" 改为 disabled
setenforce 0 让selinux生效

//可以不装这个ZendOptimizer-3.3.0a-linux-glibc21-i386.tar.gz
ZendOptimizer用来加速php
tar zxvf ZendOptimizer-3.3.0a-linux-glibc21-i386.tar.gz
#cd ZendOptimizer-3.3.0a-linux-glibc21-i386
#./install.sh

按照按照步骤安装 输入正确的安装apache的路径等内容!
安装完毕,再看看phpinfo页面的zend选项就发现了!!