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


MaxConnPerIP 2 限制每个IP的最大线程数



完成mod_bandwidth模块的安装

创建 mod_bandwidth 运行需要的目录

mkdir /var/apachebw
mkdir /var/apachebw/link
mkdir /var/apachebw/master
chmod -R 777 /var/apachebw

修改httpd.conf增加下列内容


BandWidthDataDir "/var/apachebw/"
BandWidthModule on


BandWidth 192.168.0 0 200000 制局域网内用户的下载速度为200k
BandWidth all 51200 限制其他用户的下载速度为每秒 51200 字节




修改/etc/init.d/httpd

# vi /etc/init.d/httpd

在三行之后添加如下内容:
#!/bin/sh
#
# Startup script for the Apache Web Server
# chkconfig: - 85 15
# description: Apache is a World Wide Web server. It is used to serve
# HTML files and CGI.
# processname: httpd
# pidfile: /usr/local/apache/log/httpd.pid
# config: /usr/local/apache/conf/httpd.conf

把apache服务设置为开机启动:

# chkconfig –-add httpd
# chmod 755 /etc/init.d/httpd
# chkconfig httpd on

六、安装porftpd-1.2.9

# tar –zxvf proftpd-1.2.9.tar.gz
# cd proftpd-1.2.9
# ./configure --prefix=/usr/local/proftpd
# make
# make install

建立启动文件、把proftpd设置为开机启动

# cp ./contrib/dist/rpm/proftpd.init.d /etc/rc.d/init.d/proftpd


# chkconfig --add proftpd
# chmod 755 /etc/rc.d/init.d/proftpd

# vi /etc/rc.d/init.d/functions
export PATH="/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin:/usr/local/proftpd/
sbin"

# vi /etc/rc.d/init.d/proftpd
config: /usr/local/proftpd/etc/proftpd.conf
PATH="$PATH:/usr/local/proftpd/sbin"

# chkconfig proftpd on

建立帐号和目录:

# mkdir /home/test
# chmod 755 /home/test
# adduser -d /home/test -g ftp -s /sbin/nologin test
# passwd test

# adduser -d /home/upload -g ftp -s /sbin/nologin upload
# passwd upload

配置/usr/local/proftpd/etc/proftpd.conf , 禁用匿名登陆

ServerName "llzqq"s ftp service"
ServerType standalone
DefaultServer on

# Port 21 is the standard FTP port.
Port 21

# Umask 022 is a good standard umask to prevent new dirs and files
# from being group and world writable.
Umask 022

MaxInstances 10

# Set the user and group under which the server will run.
User nobody
Group ftp

# To cause every FTP user to be "jailed" (chrooted) into their home
# directory, uncomment this line.
DefaultRoot ~

# Normally, we want files to be overwriteable.

AllowOverwrite on


# We want "welcome.msg" displayed at login, and ".message" displayed
# in each newly chdired directory.
DisplayLogin welcome.msg
DisplayFirstChdir .message
RequireValidShell no

#Limit User of being enbled login ftp server

AllowGroup ftp
DenyAll

#


DenyGroup ftp

TransferRate RETR 51200 group ftp



DenyGroup ftp

TransferRate STOR 256000 group ftp


ServerIdent off
MaxClientsPerHost 2
TimeoutIdle 600
TimeoutLogin 300
TimeoutNoTransfer 300
TimeoutStalled 300


七、reboot计算机

# shutdown –r now

打开浏览器输入:http://loaclhost/test.php

如果你看到了关于:mysql;apache;php的一大堆信息 , 恭喜 , 你的安装基本上成功了 , 下一步可以测试一下proftp和带宽的设置了 。


八、建立一个简单有效的防火墙

export PATH=/sbin:/usr/sbin:/bin:/usr/bin

modprobe iptable_nat
modprobe ip_nat_ftp
modprobe ip_nat_irc
modprobe ip_conntrack

推荐阅读