文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>建立一个带宽、线程可控的下载型WEB网站

建立一个带宽、线程可控的下载型WEB网站

时间:2009-04-29  来源:unixsly

建立一个带宽、线程可控的下载型WEB网站

一、前言

这种配置的WEB网站初步实现了IP线程和线程流量的管理,用的linux版本是RedHat AS 4.2。

二、所需要的软件及其版本

httpd-2.0.54.tar.gz
mysql-4.1.18.tar.gz
php-4.4.2.tar.gz
ZendOptimizer-2.6.2-linux-glibc21-i386.tar.gz
mod-cband-0.9.7.3.tgz   限制Apache的并发连接数以及控制Apache的带宽

三、安装配置Mysql

#  cd  /tmp
#   wget  http://ftp.ntu.edu.tw/pub/MySQL/Downloads/MySQL-4.1/mysql-4.1.18.tar.gz
#  tar  zxvf    mysql-4.1.18.tar.gz
#  cd  mysql-4.1.18
#  ./configure --prefix=/usr/local/mysql --sysconfdir=/etc --localstatedir=/var/lib/mysql
#  prefix=/usr/local/mysql   mysql安装的目标目录
#  sysconfdir=/etc   my.ini配置文件的路径
#  localstatedir=/var/lib/mysql  数据库存放的路径
#  make
#  make  install
安装完以后要初始化数据库,当然你是升级的话不用做这步;
#  /usr/local/mysql/bin/mysql_install_db
建立 mysql 用户;
#  /usr/sbin/useradd -M -o -r -d /var/lib/mysql -s /bin/bash -c "MySQL Server" -u 27 mysql
设置权限;
#  chown -R mysql:mysql /var/lib/mysql
#  chmod 750 /var/lib/mysql
#  chown -R mysql:mysql /usr/local/mysql
#  chmod -R 750 /usr/local/mysql
做完上面的步骤,然后把编译目录的一个脚本复制过去;
#  cp support-files/mysql.server /etc/rc.d/init.d/mysqld
#  chmod 755 /etc/rc.d/init.d/mysqld
#  /sbin/chkconfig --add mysqld
#  /sbin/chkconfig mysqld on    设置使 mysql 每次启动都能自动运行。
好了,至此mysql安装完毕,可以起动mysql服务
/etc/rc.d/init.d/mysqld start
下面这步比较关键;

#  ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
#  ln -s /usr/local/mysql/include/mysql /usr/include/mysql
可以不做这步,大可以在编译其他软件的时候自定义myslq的库文件路径,但最好还是把库文件链接到默认的位置,这样在编译类似PHP,Vpopmail等软件时可以不用指定mysql的库文件地址。

四、安装配置Apache

#  cd   /tmp
#  wget  http://archive.apache.org/dist/httpd/httpd-2.0.54.tar.gz
#  tar  zxvf    httpd-2.0.54.tar.gz
#  cd  httpd-2.0.54
#  ./configure --prefix=/usr/local/apache --enable-module=so --enable-speling --enable-rewrite  --enable-forward
#  so模块用来提供 DSO 支持的 apache 核心模块,rewrite是地址重写的模块,如果不需要可以不编译。
--enable-so 选项:让 Apache 可以支持DSO模式,注意,我们在这里采用的是 Apache2.0 的语法。如果你的Apache 是1.3版本,应改为--enable-module=so
--enable-mods-shared=most选项:告诉编译器将所有标准模块都编译为DSO模块。你要是用的是 Apache1.3, 改为--enable-shared=max就可以。
--enable-rewrite选项:支持地址重写功能,使用1.3版本的朋友请将它改为--enable-module=rewrite

======================== 方式 2 =============================
./configure --prefix=/usr/local/apache --enable-module=so --enable-mods-shared=most --enable-rewrite  --enable-forward
==========================================================

#  make
#  make  install
#  cp  /usr/local/apache/bin/apachectl    /etc/rc.d/init.d/httpd
#  /etc/rc.d/init.d/httpd  start

五、安装配置 PHP

#  cd  /tmp
#  wget  http://cn2.php.net/get/php-4.4.2.tar.gz/from/cn.php.net/mirror
#  tar  zxvf    php-4.4.2.tar.gz
#  cd  php-4.4.2
#  ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-apxs2=/usr/local/apache/bin/apxs
说明:
--with-apxs2=/usr/local/apache/bin/apxs 是Apache2的语法
--with-apxs=/usr/local/apache/bin/apxs 是Apache1.3的语法
#  make
#  make  install
#  cp  php.ini-dist  /usr/local/php/lib/php.ini
#  vi  /usr/local/apache/conf/httpd.conf


AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
下添加:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

重新启动 Apache 服务;
#  /etc/rc.d/init.d/httpd  restart

六、安装配置mod-cband

#  cd  /tmp
#  wget  http://cband.linux.pl/download/mod-cband-0.9.7.3.tgz
#  tar  zxvf    mod-cband-0.9.7.3.tgz
#  cd  mod-cband-0.9.7.3
#  PATH=/usr/local/apache/bin:$PATH
#  ./configure
#  make
#  make  install

在屏幕下方看到下列文字段 :

Libraries have been installed in:
  /usr/local/apache/modules
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
  - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
    during execution
  - add LIBDIR to the `LD_RUN_PATH' environment variable
    during linking
  - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
  - have your system administrator add LIBDIR to `/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
chmod 755 /usr/local/apache/modules/mod_cband.so
[activating module `cband' in /usr/local/apache/conf/httpd.conf]

如果有,则说明安装成功。

#  mkdir  /usr/local/apache/htdocs/www.test.net.cn
#  mkdir  /usr/local/apache/logs/www.test.net.cn
#  vi  /usr/local/apache/conf/httpd.conf

在配置文件的最下方添加以下内容:

NameVirtualHost 12.34.56.78    ( 主机 IP 地址 )

       ServerName www.test.net.cn:80
       ServerAdmin [email protected]
       DocumentRoot "/usr/local/apache/htdocs/www.test.net.cn "
       DirectoryIndex test.php
       ErrorLog logs/www.test.net.cn/error_log
       CustomLog logs/www.test.net.cn/access_log  common


       SetHandler  cband-status


       SetHandler  cband-status-me

RewriteEngine  on
RewriteOptions  inherit
# limit speed of this vhost to 500kb/s, 10 request/s, 30 open connections
       CbandSpeed  500kb/s    10  30
# in addition every remote host connecting to this vhost
# will be limited to 100kb/s, 5 request/s, 2 open connections
       CbandRemoteSpeed  100kb/s    5  2
       CbandPeriod  3S


#  /etc/rc.d/init.d/httpd  stop
#  /etc/rc.d/init.d/httpd  start

七、安装配置ZendOptimizer

说明:Zend Optimizer V2.5.5以上版本,就可以支持PHP5
#  cd  /tmp
#  wget  http://download.discuz.net/ZendOptimizer-2.6.2-linux-glibc21-i386.tar.gz
#  tar  zxvf    ZendOptimizer-2.6.2-linux-glibc21-i386.tar.gz
#  cd  ZendOptimizer-2.6.2-linux-glibc21-i386
#  ./install.sh

出现终端图形化安装界面,一路回车,其中有两处需要指定路径的,检查缺省是否与你的机器实现路径相符,不同则改之。如Specify the Apache bin directory,变更下方路径为你的Apache的bin目录:/usr/local/apache/bin。之后,又是一路回车至最后提示安装成功并重启apache。
Zend的安装目录一般为/usr/local/Zend/。

测试

编辑test.php文件在/usr/local/apache/htdocs/目录下,内容为:
相关阅读 更多 +
排行榜 更多 +
摧毁大厦游戏

摧毁大厦游戏

飞行射击 下载
合并动物城手游版

合并动物城手游版

休闲益智 下载
哈士奇大冒险

哈士奇大冒险

休闲益智 下载