Create a download-type WEB site with controllable bandwidth and threads

Source: Internet
Author: User
Article title: Create a download-type WEB site with controllable bandwidth and threads. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
   I. Preface
I wrote a typical configuration for a resource download website one afternoon based on my online materials and personal practices. This configuration allows WEB sites to manage IP thread and thread traffic, proftpd is used to upload resources, and ssh is used to manage hosts. Undoubtedly, this will allow you to control your valuable network bandwidth. a simple firewall configuration is provided later in this article for your reference. my linux version is redhat as 3.0. Hope you have read this article after a lot of exchanges with me, MAIL: LLZQQ@163.COM
  
   II. software version
Apache-1.3.29
Mysql-4.0.16
Php-4.3.4
Proftpd-1.2.9
Mod_limitipconn-0.04
Mod_bandwidth-2.0.4
  
   III. install and configure Mysql
# Cd mysql-4.0.16
  
#./Configure -- prefix =/usr/local/mysql -- localstatedir =/usr/local/mysql/data
-- Disable-maintainer-mode? With-mysqld-user = mysql -- enable-large-files-without-debug
  
# Make
# Make install
  
Add a mysql User
  
#/Usr/sbin/groupadd mysql
  
Then we create a user called mysql which belongs to the mysql group;
  
#/Usr/sbin/useradd-g mysql
  
Install the database file:
  
#./Scripts/mysql_install_db
  
Set file permissions:
  
# Chown-R root: mysql/usr/local/mysql
# Chown-R mysql: mysql/usr/local/mysql/data
  
Configure ld. so. conf
  
# Vi/etc/ld. so. conf
  
Add the following sentence:
  
/Usr/local/mysql/lib/mysql
  
Create a mysql startup file:
  
# Cp support-files/mysql. server/etc/init. d/mysql
# Cp support-files/my-medium.cnf/etc/my. cnf
  
Start mysql in safe mode:
  
#/Usr/local/mysql/bin/mysqld_safe? User = mysql &
  
Set the mysql root password:
  
#/Usr/local/mysql/bin/mysqladmin-u root password new_password
  
Set the mysql service to start upon startup:
  
# Chmod 755/etc/init. d/mysql
# Chkconfig? -Add mysql
# Chkconfig mysql on
  
   4. install and configure PHP
# Cd php-4.3.4
  
#./Configure -- prefix =/usr/local/php -- with-apxs =/usr/local/apache/bin/apxs -- with-mysql =/usr/local/mysql
  
# Make
# Make install
  
Create a php configuration file:
  
# Cp php. ini-dist/usr/local/php/lib/php. ini
  
Modify the php configuration file:
  
# Vi/usr/local/php/lib/php. ini
  
Doc_root = "/home/www /"
File_uploads = Off
Register-golbals = On
  
Create a test php page
  
# Vi/home/www/test. php
  
  
  
# Chomd 755/home/www/test. php
  
   5. install apache-1.3.29
# Tar zvxf apache_1.3.29.tar.gz
# Cd apache_1.3.29
# Cp ../mod_bandwidth.c
  
Modify src/include/httpd. h to increase the maximum number of threads
# Vi src/include/httpd. h
  
Modify
# Define HARD_SERVER_LIMIT 256
Is
# Define HARD_SERVER_LIMIT 2560
  
#./Configure -- prefix =/usr/local/apache -- enable-module = so
-- Enable-module = rewrite -- enable-shared = max
-- Htdocsdir =/home/www -- add-module = mod_bandwidth.c
-- Permute-module = BEGIN: bandwidth
  
# Make
# Make install
  
Create a startup file:
  
# Cp apachectl/etc/init. d/httpd
  
Modify the apache configuration file:
  
# Vi/usr/local/apache/conf/httpd. conf
  
Modify, add, and confirm the following configuration items:
  
Adddefacharcharset GB2312 comment out "addDefaultCharset ISO8859 *"
ExtendedStatus On
LoadModule php4_module modules/libphp4.so
DirectoryIndex index.html. var index. php
AddType application/x-httpd-php. php
AddType application/x-httpd-php-source. phps
LoadModule limitipconn_module libexec/mod_limitipconn.so
AddModule mod_limitipconn.c
  
Install mod_limitipconn-0.04
  
# Tar xzf mod_limitipconn-0.04.tar.gz
# Cd mod_limitipconn-0.04
# Vi Makefile
   
APXS =/usr/local/apache/bin/apxs
  
# Make
# Make install
  
To use the mod_limitip module, add this setting in httpd. conf.
  
    
   Set the directory to be controlled
MaxConnPerIP 2 limits the maximum number of threads per IP
   
  
  
Install the mod_bandwidth module
  
Create a directory required to run mod_bandwidth
  
Mkdir/var/apachebw
Mkdir/var/apachebw/link
Mkdir/var/apachebw/master
Chmod-R 777/var/apachebw
  
Modify httpd. conf to add the following content:
  
    
BandWidthDataDir "/var/apachebw /"
BandWidthModule on
  
    
BandWidth 192.168.0 0 200000: the download speed of users in the Lan is 200 KB.
BandWidth all 51200 limits the download speed of other users to 51200 bytes per second
    
  
  
  
Modify/etc/init. d/httpd
  
# Vi/etc/init. d/httpd
  
Add the following content after three rows:
#! /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
  
Set apache service to start at startup:
  
# Chkconfig? -Add httpd
# Chmod 755/etc/init. d/httpd
# Chkconfig httpd on
  
   6. install 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
  
Create a startup file and set proftpd to boot
  
# 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/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
  
Create an account and directory:
  
# 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
  
Configure/usr/local/proftpd/etc/proftpd. conf and disable anonymous logon.
  
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
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.