以下安装过程为我在**网工作期间,**网整个外网所需服务的安装过程以及注意事项

一  安装所需软件包
 LANG=C
 yum -y install gcc gcc-c++ gd* autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers readline readline-devel libtool libtool-ltdl  libtool-ltdl-devel *ltdl*
二、安装PHP 5.2.13(FastCGI模式)
 1、编译安装PHP 5.2.13所需的支持库:
 tar zxvf libiconv-1.13.tar.gz
 cd libiconv-1.13/
 ./configure --prefix=/usr/local/web_server/
 (make ZEND_EXTRA_LIBS='-liconv')
 make && make install

 tar zxvf libmcrypt-2.5.8.tar.gz
 cd libmcrypt-2.5.8/
 ./configure --prefix=/usr/local/web_server/
 make && make install
 /sbin/ldconfig
 cd libltdl/
 ./configure --prefix=/usr/local/web_server/ --enable-ltdl-install
 make && make install

 tar zxvf mhash-0.9.9.9.tar.gz
 cd mhash-0.9.9.9/
 ./configure --prefix=/usr/local/web_server/
 make && make install
 ./configure
 make && make install

 tar zxvf libevent-1.4.10-stable.tar.gz        ( http://monkey.org/~provos/libevent-1.4.9-stable.tar.gz
 cd libevent-1.4.10-stable  
 ./configure --prefix=/usr/local/web_server/libevent
 make && make install 

32位机器:
 ln -s /usr/local/web_server/lib/libmcrypt.la /usr/lib/libmcrypt.la
 ln -s /usr/local/web_server/lib/libmcrypt.so /usr/lib/libmcrypt.so
 ln -s /usr/local/web_server/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
 ln -s /usr/local/web_server/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
 ln -s /usr/local/web_server/lib/libmhash.a /usr/lib/libmhash.a
 ln -s /usr/local/web_server/lib/libmhash.la /usr/lib/libmhash.la
 ln -s /usr/local/web_server/lib/libmhash.so /usr/lib/libmhash.so
 ln -s /usr/local/web_server/lib/libmhash.so.2 /usr/lib/libmhash.so.2
 ln -s /usr/local/web_server/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
64位机器:
 ln -s /usr/local/web_server/lib/libmcrypt.la /usr/lib64/libmcrypt.la
 ln -s /usr/local/web_server/lib/libmcrypt.so /usr/lib64/libmcrypt.so
 ln -s /usr/local/web_server/lib/libmcrypt.so.4 /usr/lib64/libmcrypt.so.4
 ln -s /usr/local/web_server/lib/libmcrypt.so.4.4.8 /usr/lib64/libmcrypt.so.4.4.8
 ln -s /usr/local/web_server/lib/libmhash.a /usr/lib64/libmhash.a
 ln -s /usr/local/web_server/lib/libmhash.la /usr/lib64/libmhash.la
 ln -s /usr/local/web_server/lib/libmhash.so /usr/lib64/libmhash.so
 ln -s /usr/local/web_server/lib/libmhash.so.2 /usr/lib64/libmhash.so.2
 ln -s /usr/local/web_server/lib/libmhash.so.2.0.1 /usr/lib64/libmhash.so.2.0.1
 tar zxvf mcrypt-2.6.8.tar.gz
 cd mcrypt-2.6.8/
 /sbin/ldconfig
 ./configure --prefix=/usr/local/web_server/ --with-libmcrypt-prefix=/usr/local/web_server/ --with-libiconv-prefix=/usr/local/web_server/
 make && make install

2、编译安装MySQL 5.1.44
 /usr/sbin/groupadd mysql
 /usr/sbin/useradd -g mysql mysql
 tar zxvf mysql-5.1.44.tar.gz
 cd mysql-5.1.44/
 ./configure --prefix=/usr/local/web_server/mysql/ --enable-shared --enable-assembler --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-plugins=innobase --with-charset=utf8 --with-extra-charsets=gbk,gb2312,utf8 --with-mysqld-user=mysql
 make && make install
 mkdir /usr/local/web_server/mysql/var
 mkdir /usr/local/web_server/mysql/tmp
 mkdir /usr/local/web_server/mysql/logs
 mkdir /usr/local/web_server/mysql/etc
 chmod +w /usr/local/web_server/mysql/
 chown -R mysql:mysql /usr/local/web_server/mysql/
 cp support-files/mysql.server /etc/init.d/mysqld
 chmod 700 /etc/init.d/mysqld
 cp support-files/my-huge.cnf /etc/my.cnf
 /usr/local/web_server/mysql/bin/mysql_install_db --basedir=/usr/local/web_server/ --datadir=/usr/local/web_server/mysql/var --user=mysql
 登陆到mysql,执行一下语句:
 grant all PRIVILEGES on *.* to mysql@'localhost' identified by '123456';
 grant all PRIVILEGES on *.* to mysql@'%' identified by '123456';
 执行了上面的语句后,再执行下面的语句,方可立即生效。
 flush privileges;

3. 安装postgresql
 /usr/sbin/groupadd postgres
 /usr/sbin/useradd -g postgres postgres
 tar jxvf postgresql-8.3.12.tar.bz2
 cd postgresql-8.3.12
 ./configure --prefix=/usr/local/web_server/pgsql
 make && make install
 chmod +w /usr/local/web_server/pgsql/
 chown -R postgres:postgres /usr/local/web_server/pgsql/

4、编译安装PHP(FastCGI模式)
 tar zxvf php-5.2.13.tar.gz
 gzip -cd php-5.2.13-fpm-0.5.13.diff.gz | patch -d php-5.2.13 -p1
 cd php-5.2.13
 ./configure --prefix=/usr/local/web_server/php5 --with-config-file-path=/usr/local/web_server/php5/etc --with-pgsql=/usr/local/web_server/pgsql --with-pdo-pgsql=/usr/local/web_server/pgsql --with-iconv-dir=/usr/local/web_server/ --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --with-libevent=/usr/local/web_server/libevent/ --enable-force-cgi-redirect --enable-mbstring=all --with-mcrypt=/usr/local/web_server/ --with-gd --enable-gd-native-ttf --with-openssl --with-pcre-dir=/usr/local/web_server/pcre/ --with-pcre-regex=/usr/local/web_server/pcre --with-mhash --enable-pcntl --enable-sockets --without-sqlite --without-pdo-sqlite --enable-memcache --enable-zip --with-mysql=/usr/local/web_server/mysql --with-mysqli=/usr/local/web_server/mysql/bin/mysql_config --with-pdo-mysql=shared,/usr/local/web_server/mysql --enable-sysvshm
  ZEND_EXTRA_LIBS='-liconv' make
  (如果出现错误,按照以下方式做
  编辑 Makefile 大约 70 行左右的地方:
  EXTRA_LIBS = ….. -lcrypt
  在最后加上 -liconv,例如:
  EXTRA_LIBS = ….. -lcrypt -liconv
  然后重新再次 make 即可,不用make clean 直接make)
 make install
 cp php.ini-dist /usr/local/web_server/php5/etc/php.ini

5、编译安装PHP5扩展模块    (参考:http://willko.javaeye.com/blog/332993)
 安装memcached (memcached: http://www.danga.com/memcached/dist/memcached-1.2.6.tar.gz
 tar zxvf memcached-1.4.5.tar.gz  
 cd memcached-1.4.5
 ./configure --prefix=/usr/local/web_server/memcached --enable-threads --enable-64bit --with-libevent=/usr/local/web_server/libevent/
 make && make install

php安装对memcached的支持
   php有两个版本的memcached客户端
 1.memcached
 这个是新版的客户端基于libmemcached,所以必须要安装libmemcached
 先安装libmemcached
 下载地址:http://download.tangent.org/libmemcached-0.44.tar.gz
 tar zxvf libmemcached-0.44.tar.gz
 cd libmemcached-0.44
 ./configure --prefix=/usr/local/web_server/libmemcached/ --with-memcached --with-libevent-prefix=/usr/local/web_server/libevent/
 make && make install

 安装php memcached客户端
 下载地址:http://pecl.php.net/get/memcached
 tar zxvf memcached-0.1.4.tgz
 cd memcached-0.1.4
 /usr/local/web_server/php5/bin/phpize
 ./configure --prefix=/usr/local/web_server --with-php-config=/usr/local/web_server/php5/bin/php-config --with-libmemcached-dir=/usr/local/web_server/libmemcached/ --enable-memcached
 make && make instal
 2.memcache
 下载地址:http://pecl.php.net/get/memcache
 tar zxvf memcache-2.2.5.tgz
 cd memcache-2.2.5
 /usr/local/web_server/php5/bin/phpize
 ./configure --prefix=/usr/local/web_server --with-php-config=/usr/local/web_server/php5/bin/php-config --enable-memcache
 make && make instal

 tar jxvf eaccelerator-0.9.6.1.tar.bz2
 cd eaccelerator-0.9.6.1/
 /usr/local/web_server/php5/bin/phpize
 ./configure --prefix=/usr/local/web_server/ --enable-eaccelerator=shared --with-php-config=/usr/local/web_server/php5/bin/php-config
 make
 make install
 
 按shift+g键跳到配置文件(php.ini)的最末尾,加上以下配置信息:
 引用
 [eaccelerator]
 zend_extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"
 eaccelerator.shm_size="64"
 eaccelerator.cache_dir="/usr/local/eaccelerator_cache"
 eaccelerator.enable="1"
 eaccelerator.optimizer="1"
 eaccelerator.check_mtime="1"
 eaccelerator.debug="0"
 eaccelerator.filter=""
 eaccelerator.shm_max="0"
 eaccelerator.shm_ttl="3600"
 eaccelerator.shm_prune_period="3600"
 eaccelerator.shm_only="0"
 eaccelerator.compress="1"
 eaccelerator.compress_level="9"

 tar zxvf PDO_MYSQL-1.0.2.tgz
 cd PDO_MYSQL-1.0.2/
 /usr/local/web_server/php5/bin/phpize
 ./configure --prefix=/usr/local/web_server/ --with-php-config=/usr/local/web_server/php5/bin/php-config --with-pdo-mysql=/usr/local/web_server/mysql
 make
 make install

 tar zxvf PDO_MYSQL-1.0.2.tgz
 cd PDO_MYSQL-1.0.2
 /usr/local/web_server/php5/bin/phpize
 ./configure --prefix=/usr/local/web_server/ --with-php-config=/usr/local/web_server/php5/bin/php-config --with-pdo-pgsql=/usr/local/web_server/pgsql/
 make
 make install

 tar zxvf ImageMagick.tar.gz
 cd ImageMagick-6.5.1-2/
 ./configure --prefix=/usr/local/web_server/
 make
 make install

 tar zxvf imagick-2.3.0.tgz
 cd imagick-2.3.0/
 /usr/local/web_server/php5/bin/phpize
 ./configure --prefix=/usr/local/web_server/ --with-php-config=/usr/local/web_server/php5/bin/php-config --with-imagick=/usr/local/web_server/
 make
 make install
 
 wget http://www.ftphp.com/scws/down/scws-dict-chs-utf8.tar.bz2
 wget http://www.ftphp.com/scws/down/scws-dict-chs-gbk.tar.bz2
 tar jxvf scws-1.1.3.tar.bz2
 cd scws-1.1.3
 ./configure --prefix=/usr/local/web_server/scws
 make
 make install
 cd /usr/local/src
 tar jxvf scws-dict-chs-utf8.tar.bz2 -C /usr/local/web_server/scws/etc/
 tar jxvf scws-dict-chs-gbk.tar.bz2 -C /usr/local/web_server/scws/etc/
 cd scws-1.1.3/phpext/
 /usr/local/web_server/php5/bin/phpize
 ./configure --with-scws=/usr/local/web_server/scws/ --with-php-config=/usr/local/web_server/php5/bin/php-config
 make
 make install

6、安装Nginx
 tar zxvf pcre-8.10.tar.gz
 cd pcre-8.10
 ./configure --prefix=/usr/local/web_server/pcre
 make
 make install
 cp -r ../pcre-8.10 /usr/local/web_server/pcre/

 tar zxvf google-perftools-0.98.tar.gz
 cd google-perftools-0.98
 ./configure --prefix=/usr/local/web_server/google-perftools --enable-frame-pointers
 make
 make install
 cp /usr/local/web_server/google-perftools/lib/* /usr/lib/
 
 /usr/sbin/groupadd www
 /usr/sbin/useradd -g www www
 tar zxvf nginx-0.8.36.tar.gz
 cd nginx-0.8.36/
 ./configure --prefix=/usr/local/web_server/nginx --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/local/web_server/pcre/pcre-8.10/ --with-google_perftools_module(动态机器)
 --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/local/web_server/pcre/pcre-8.10/ --with-google_perftools_module --with-http_perl_module --with-debug(静态机器)
 make && make install