在CentOS 5.2和CentOS 4.7 Server版本中测试均无任何错误,
一,首先升级更新系统各种库(基本完整)
yum -y install patch make gcc gcc-c++ autoconf kernel-devel 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 yum -y install fonts-chinese scim-chewing scim-pinyin scim-tables-chinese
二,下载所需软件:
wget http://leoz.googlecode.com/files/nginx-0.7.19.tar.gz wget http://leoz.googlecode.com/files/php-5.2.6.tar.gz wget http://leoz.googlecode.com/files/php-5.2.6-fpm-0.5.9.diff.gz wget http://leoz.googlecode.com/files/libiconv-1.12.tar.gz wget http://leoz.googlecode.com/files/libmcrypt-2.5.8.tar.gz wget http://leoz.googlecode.com/files/mcrypt-2.6.7.tar.gz wget http://leoz.googlecode.com/files/memcache-2.2.3.tgz wget http://leoz.googlecode.com/files/mhash-0.9.9.tar.gz wget http://leoz.googlecode.com/files/pcre-7.7.tar.gz wget http://leoz.googlecode.com/files/eaccelerator-0.9.5.3.tar.bz2 wget http://leoz.googlecode.com/files/mysql-5.0.22.tar.gz wget http://leoz.googlecode.com/files/phpMyAdmin-3.1.1-all-languages.tar.gz
三,安装PHP环境支持包(就是上面的包)
tar zxvf libiconv-1.12.tar.gz cd libiconv-1.12/ ./configure –prefix=/usr/local make make install cd ../
tar zxvf libmcrypt-2.5.8.tar.gz cd libmcrypt-2.5.8/ ./configure make make install /sbin/ldconfig cd libltdl/ ./configure –enable-ltdl-install make make install cd ../../
tar zxvf mhash-0.9.9.tar.gz cd mhash-0.9.9/ ./configure make make install cd ../
cp /usr/local/lib/libmcrypt.* /usr/lib ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
tar zxvf mcrypt-2.6.7.tar.gz cd mcrypt-2.6.7/ ./configure make make install cd ../
四,安装Mysql
tar -zxvf mysql-5.0.22.tar.gz cd mysql-5.0.22 ./configure –prefix=/usr/local/webserver/mysql –enable-assembler –with-charset=utf8 –enable-thread-safe-client –with-extra-charsets=all –without-innodb –without-isam make;make install cd ../ groupadd mysql useradd -g mysql mysql cp /usr/local/webserver/mysql/share/mysql/my-medium.cnf /etc/my.cnf /usr/local/webserver/mysql/bin/mysql_install_db –user=mysql chown -R mysql /usr/local/webserver/mysql/var chgrp -R mysql /usr/local/webserver/mysql/. cp /usr/local/webserver/mysql/share/mysql/mysql.server /etc/init.d/mysql chmod 755 /etc/init.d/mysql chkconfig –level 345 mysql on echo “/usr/local/mysql/lib/mysql” » /etc/ld.so.conf echo “/usr/local/lib” »/etc/ld.so.conf ldconfig ln -s /usr/local/webserver/mysql/lib/mysql /usr/lib/mysql ln -s /usr/local/webserver/mysql/include/mysql /usr/include/mysql service mysql start /usr/local/mysql/bin/mysqladmin -u root password root service mysql restart service mysql stop
五,安装PHP
tar zxvf php-5.2.8.tar.gz gzip -cd php-5.2.8-fpm-0.5.10.diff.gz | patch -d php-5.2.8 -p1 cd php-5.2.8/ ./configure –prefix=/usr/local/php –with-config-file-path=/usr/local/php/etc –with-mysql=/usr/local/mysql –with-mysqli=/usr/local/mysql/bin/mysql_config –with-iconv-dir=/usr/local –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 –enable-force-cgi-redirect –enable-mbstring –with-mcrypt –with-gd –enable-gd-native-ttf –with-openssl –with-mhash –enable-pcntl –enable-sockets make ZEND_EXTRA_LIBS=’-liconv’ make install cp php.ini-dist /usr/local/php/etc/php.ini cd ../
make make install cp php.ini-dist /usr/local/php/etc/php.ini cd ../
六,安装配置eaccelerator+memcache
tar zxvf memcache-2.2.3.tgz cd memcache-2.2.3/ /usr/local/php/bin/phpize ./configure –with-php-config=/usr/local/php/bin/php-config make make install cd ../
tar jxvf eaccelerator-0.9.5.3.tar.bz2 cd eaccelerator-0.9.5.3/ /usr/local/php/bin/phpize ./configure –enable-eaccelerator=shared –with-php-config=/usr/local/php/bin/php-config make make install cd ../
sed -i ’s#extension_dir = “./"#extension_dir = “/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/”\nextension = “memcache.so”\n#’ /usr/local/php/etc/php.ini sed -i ’s#output_buffering = Off#output_buffering = On#’ /usr/local/php/etc/php.ini
mkdir -p /usr/local/eaccelerator_cache cat »/usr/local/php/etc/php.ini«EOF [eaccelerator] zend_extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so” eaccelerator.shm_size=“1” 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” eaccelerator.keys = “disk_only” eaccelerator.sessions = “disk_only” eaccelerator.content = “disk_only” #[eaccelerator] #zend_extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so" #eaccelerator.shm_size=“128” #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=“300” #eaccelerator.shm_prune_period=“120” #eaccelerator.shm_only=“0” #eaccelerator.compress=“1” #eaccelerator.compress_level=“9”
七,创建www用户和用户组,
groupadd www useradd -g www www mkdir -p /web/www chmod +w /web/www mkdir -p /web/logs chmod 777 /web/logs
chown -R www:www /web/www rm -f /usr/local/php/etc/php-fpm.conf cp conf/php-fpm.conf /usr/local/php/etc/php-fpm.conf
echo “ulimit -SHn 51200” >/root/run.sh echo “/usr/local/php/sbin/php-fpm start” »/root/run.sh
八,安装Nginx
tar zxvf pcre-7.7.tar.gz cd pcre-7.7/ ./configure make && make install cd ../ tar zxvf nginx-0.7.19.tar.gz cd nginx-0.7.19/ ./configure –user=www –group=www –prefix=/usr/local/nginx –with-http_stub_status_module –with-http_ssl_module make && make install cd ../ rm -f /usr/local/nginx/conf/nginx.conf cp conf/nginx.conf /usr/local/nginx/conf/nginx.conf sed -i ’s/www.xxxx.com/’$domain’/g’ /usr/local/nginx/conf/nginx.conf
rm -f /usr/local/nginx/conf/fcgi.conf cp conf/fcgi.conf /usr/local/nginx/conf/fcgi.conf
echo “/usr/local/nginx/sbin/nginx” »/root/run.sh chmod 777 /root/run.sh service mysql start /root/run.sh
九,安装phpmyadmin
tar zxvf phpMyAdmin-3.1.1-all-languages.tar.gz mv phpMyAdmin-3.1.1-all-languages /web/www/phpmyadmin
十,加入开机自启动
echo “ulimit -SHn 51200” »/etc/rc.local echo “/usr/local/php/sbin/php-fpm start” »/etc/rc.local echo “/usr/local/nginx/sbin/nginx” »/etc/rc.local