yuki_365170a716 2008-8-6 10:17
针对中小型网站的服务器架构(一)
但是针对部分企业, 这个方案也是一个非常不错的选择!
至于nginx和apache等[url=http://webservices.ctocio.com.cn/]web服务[/url]器的性能比较这里就不多说了
本文是以实例的方式来描述安装以及配置等情况, 供各位参考
1. 硬件环境
一台web[url=http://server.ctocio.com.cn/]服务器[/url], 一台db服务器, 没有raid
web服务器 至强双核1.60GHz, 2G, 73GSCSI*2
db服务器 至强双核1.60GHz, 2G, 73GSCSI*2
2. 系统环境
CentOS 5.x (内核2.6+)
简单的说下前期工作:安装系统尽可能的精简, 检查系统时间, dmesg看看有无错误, 关闭selinux,ipv6, 升级系统到最新yum -y update
安装如下web环境必要的软件包:
# yum install -y ntp vim-enhanced gcc gcc-c++ gcc-g77 flex bison autoconf automake bzip2-devel ncurses-devel libjpeg-devel libpng-devel libtiff-devel freetyp[url=http://whatis.ctocio.com.cn/searchwhatis/246/5947746.shtml]e-[/url]devel pam-devel [url=http://whatis.ctocio.com.cn/searchwhatis/24/5948524.shtml]kernel[/url]
3. 准备软件
nginx-0.6.31.[url=http://whatis.ctocio.com.cn/searchwhatis/85/6092585.shtml]tar[/url].gz
pcre-7.3.tar.gz
php-5.2.6.tar.bz2
eaccelerator-0.9.5.3.tar.bz2
ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz
lighttpd-1.4.19.tar.bz2
libxml2-2.6.30.tar.gz
libmcrypt-2.5.8.tar.bz2
gd-2.0.34.tar.gz
[url=http://database.ctocio.com.cn/mysql/]mysql[/url]-5.0.51a-linux-i686-glibc23.tar.gz
以上软件都是目前最新最稳定的版本, 查找和下载以上软件或者更新版本
请在[url=http://www.google.com]www.google.com[/url]输入: 软件全名 intitle:index
一般头几个都是可以下载的, 找个最快的就可以了
4.开始安装环境:
(1)安装gd库
# tar zxvf gd-2.0.34.tar.gz
# cd gd-2.0.34
# ./[url=http://whatis.ctocio.com.cn/searchwhatis/390/5947390.shtml]configure[/url] --prefix=/usr/local/gd2
# make
# make install
(2)安装LibXML2
# tar zxvf libxml2-2.6.30.tar.gz
# cd libxml2-2.6.30
# ./configure --prefix=/usr/local/libxml2
# make
# make install
(3)安装LibMcrypt
# cd /usr/local/src
# tar jxvf libmcrypt-2.5.8.tar.bz2
# cd libmcrypt-2.5.8
# ./configure --prefix=/usr/local/libmcrypt
# make
# make install
(4)解压mysql-5.0.51a-linux-i686-glibc23.tar.gz, 然后把解开的包里的lib和include目录转移到任意目录, 例如/usr/local/mysql
因为编译php5需要用到mysql的支持(--with-mysql)
# tar zxvf mysql-5.0.51a-linux-i686-glibc23.tar.gz
# cd mysql-5.0.51a-linux-i686-glibc23
# mkdir -p /user/local/mysql
# mv ./lib ./include /user/local/mysql/
(5)编译php(fastcfi模式)
# ./configure --prefix=/usr/local/php-fcgi --enable-fastcgi--enable-discard-[url=http://whatis.ctocio.com.cn/searchwhatis/448/6025948.shtml]path[/url] --enable-[url=http://whatis.ctocio.com.cn/searchwhatis/460/5947960.shtml]force[/url]-cgi-[url=http://whatis.ctocio.com.cn/searchwhatis/67/6093567.shtml]redirect[/url]--with-config-[url=http://whatis.ctocio.com.cn/searchwhatis/398/5947898.shtml]file[/url]-path=/usr/local/php-fcgi/etc --enable-zend-multibyte--with-mysql=/usr/local/mysql --with-libxml-dir=/usr/local/libxml2--with-gd=/usr/local/gd2 --with-jpeg-dir --with-png-dir --with-bz2--with-freetype-dir --with-iconv-dir --with-zlib-dir--with-mcrypt=/usr/local/libmcrypt --enable-sysvsem--enable-inline-optimization --enable-soap --enable-gd-[url=http://whatis.ctocio.com.cn/searchwhatis/326/6093326.shtml]native[/url]-ttf--enable-ftp --enable-mbstring --enable-exif --disable-[url=http://whatis.ctocio.com.cn/searchwhatis/168/5947668.shtml]debug[/url]--disable-ipv6
# make
# make install
# cp php.ini-dist /usr/local/php-fcgi/etc/php.ini
(6)安装ZendOptimizer
# tar zxvf ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz
# cd ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz
# ./install
基本上是一直回车, 值得注意一点的是:
当您看到要选择php的路径时就写:
/usr/local/php-fcgi/etc
看到Are you using [url=http://whatis.ctocio.com.cn/searchwhatis/299/6025299.shtml]Apache[/url] Web [url=http://whatis.ctocio.com.cn/searchwhatis/497/5948997.shtml]server[/url]?
这里要选NO
(7)安装eaccelerator
# tar jxvf eaccelerator-0.9.5.3.tar.bz2
# cd eaccelerator-0.9.5.3
# ./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php-fcgi/bin/php-config
# make
# make install
# mkdir /tmp/eaccelerator && [url=http://whatis.ctocio.com.cn/searchwhatis/185/5947185.shtml]chmod[/url] 777 /tmp/eaccelerator && touch /var/log/eaccelerator_log
编辑php.ini
# vi /usr/local/php-fcgi/etc/php.ini
在最底部加上:
[url=http://whatis.ctocio.com.cn/searchwhatis/399/5947899.shtml]extension[/url]=/usr/local/php-fcgi/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so
eaccelerator.shm_size="16"
eaccelerator.cache_dir="/tmp/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.log_file = "/var/log/eaccelerator_log"
eaccelerator.[url=http://whatis.ctocio.com.cn/searchwhatis/408/5947908.shtml]filter[/url]=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="0"
eaccelerator.shm_prune_period="0"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"
alangchen156066 2008-8-7 14:49
good