The fourth chapter constructs the Lamp website service Platform
Lab Report
1. Installing Apache server Software and related components
Check to see if the Apache service-related packages are installed on your system:
[Email protected]/]# Rpm-qa | grep httpd
----------------------------------------------------------------
HTTPD-2.2.3-31.EL5 Apache Server program Package
HTTPD-MANUAL-2.2.3-31.EL5 Apache Server Help manual documentation
----------------------------------------------------------------
Just need to include these 2 packages!
2. View the installed directories and files
[Email protected]/]# RPM-QL httpd
[Email protected]/]# RPM-QL httpd-manual
The main directories and files related to the Apache server are as follows:
----------------------------------------------------------------
/ETC/HTTPD the root directory of the Apache server program
/etc/httpd/conf/httpd.conf Apache Server Master configuration file
/ETC/HTTPD/CONF.D Apache Server other function module configuration file directory, such as MySQL, PHP, SSL, Perl and other configuration files
/var/www/html default root directory for Web page documents
Script control files for/ETC/INIT.D/HTTPD Apache server
/USR/SBIN/HTTPD Apache server's main execution program
/var/log/httpd/access_log Access log files
/var/log/httpd/error_log error log file
Script control files for/usr/sbin/apachectl Apache server
/usr/bin/ab Apache comes with a stress test tool (Apache benchmark tool)
/USR/BIN/HTPASSWD the password file that generated the authentication user
/usr/lib/httpd/modules Apache Server Module Storage Directory
/VAR/LOG/HTTPD storing Apache log files
----------------------------------------------------------------
3, by default, the main configuration file to make the necessary changes to build a basic available Web server
##### Split Line build a basic available Web Server # # #
Basic steps:
(1) Modify the Master profile httpd.conf
Remove Comments: #ServerName www.example.com:80
Modified to: ServerName www.benet.com:80
Need to have DNS server support, first build DNS server
(2) Check the main configuration file httpd.conf for syntax errors
Method One: Apachectl-t
Method Two: Httpd–t
(3) Start httpd service
[[Email protected]/]# service httpd start
(4) Check if the HTTPD service port is open
[Email protected]/]# NETSTAT-ANPT | grep 80
(5) Accessing the test through the browser on the client
http://www.benet.com/
######### Split Line Test Web Server Performance ###########
Basic steps:
(1) Use the Ulimit command to modify the maximum number of files limit to 10000
Ulimit-n 10000
(2) pressure test with ab command
[Email protected]/]# ab-q-C 2000-n 4000 http://www.benet.com/
(3) View the statistical information obtained
######## Split Line build based on ip/ Port/ domain name of the virtual host ##########
Basic steps:
******** implement IP-based the virtual host ********
(1) Create a virtual host test Web document
Assume that the current Web server has 3 virtual hosts
Virtual host one corresponding to the main directory/var/www/html
Virtual host two corresponding to the main directory/var/www/xuni2
Virtual host three corresponding to the main directory/var/www/xuni3
[Email protected]/]# cd/var/www
[Email protected] www]# mkdir xuni2 Xuni3
Place the test Web document in 3 directories, with the default name index.html
Refer to the Web document HTML code:
<title>
~~~~~~~~~~~~~virtual host~~~~~~~~~~~
</title>
<body bgcolor=blue>
<p align=center>
############# #Virtual host###########
</p>
</body>
(2) Set 2 virtual interfaces for the current server and assign IP addresses
[Email protected]/]# ifconfig eth0:0 192.168.100.3 netmask 255.255.255.0
[Email protected]/]# ifconfig eth0:1 192.168.100.4 netmask 255.255.255.0
(3) Modify the Apache Master Profile httpd.conf, configure the virtual host
[Email protected]/]# vi/etc/httpd/conf/httpd.conf
Navigate to Last row
<virtualhost 192.168.100.2:80>
Documentroot/var/www/html
ServerName host1//The host name of the virtual host is set here
</VirtualHost>
<virtualhost 192.168.100.3:80>
Documentroot/var/www/xuni2
ServerName Host2
</VirtualHost>
<virtualhost 192.168.100.4:80>
Documentroot/var/www/xuni3
ServerName Host3
</VirtualHost>
(4) Restart the HTTPD service to access the test through the browser on the client
Http://192.168.100.2/
http://192.168.100.3/
http://192.168.100.4/
******** implementing a Port-based virtual host ********
(5) Remove the 2 virtual interfaces you just added
[Email protected]/]# ifconfig eth0:0 down
[Email protected]/]# ifconfig eth0:1 down
(6) Modify the Apache Master Profile httpd.conf, configure the virtual host
Navigate to Last row
Modify the Listen parameter to:
Listen 192.168.100.2:80
Listen 192.168.100.2:81
Listen 192.168.100.2:82
Modify the virtual host parameters as:
<virtualhost 192.168.100.2:80>
Documentroot/var/www/html
ServerName host1
</VirtualHost>
<virtualhost 192.168.100.2:81>
Documentroot/var/www/xuni2
ServerName HOST2
</VirtualHost>
<virtualhost 192.168.100.2:82>
Documentroot/var/www/xuni3
ServerName HOST3
</VirtualHost>
(7) Restart the HTTPD service to access the test through the browser on the client
Http://192.168.100.2/
http://192.168.100.2:81/
http://192.168.100.2:82/
******** implementing Domain-based virtual host ********
(8) Configuring DNS servers, creating zones and corresponding host names
Www.benet.com 192.168.100.2
Www.accp.com 192.168.100.2
Www.btest.com 192.168.100.2
Configuration steps slightly
(9) Modify the Apache Master Profile httpd.conf, configure the virtual host
Navigate to Last row
Modify the Listen parameter to:
Listen 192.168.100.2:80
Modify the virtual host parameters as:
Na</virtualhost>
<virtualhost 192.168.100.2:80>
Documentroot/var/www/xuni2
ServerName www.accp.com
</VirtualHost>
<virtualhost 192.168.100.2:80>
Documentroot/var/www/xuni3
ServerName www.btest.com
</VirtualHost>
(10) Restart the HTTPD service to access the test through the browser on the client
http://www.benet.com/
http://www.accp.com/
http://www.btest.com/
########## Split Line set up a system user's profile page #####################
(1) Modify the Apache Master Profile httpd.conf to enable the Apache profile feature
Verify that there are parameters in the main configuration file:
LoadModule Userdir_module modules/mod_userdir.so
Set parameters:
<ifmodule mod_userdir.c>
Userdir public_html
</IfModule>
<Directory/home/*/public_html>
allowoverride FileInfo authconfig Limit
Options multiviews Indexes SymLinksIfOwnerMatch includesnoexec
<limit GET POST options>
Order Allow,deny
Allow from all
</Limit>
<limitexcept GET POST options>
Order Deny,allow
Deny from all
</LimitExcept>
</Directory>
(2) Set up a system user and set up a personal homepage test file
Create test users UserA and UserB
[Email protected] named]# Su-usera
[Email protected] ~]$ mkdir public_html
[Email protected] ~]$ echo "UserA's Home page" > public_html/index.html
[Email protected] ~]$ chmod O+x/home/usera
[Email protected] named]# Su-userb
[Email protected] ~]$ mkdir public_html
[Email protected] ~]$ echo "UserB's Home page" > public_html/index.html
[Email protected] ~]$ chmod o+x/home/userb
(3) Restart HTTPD service
Service httpd Restart
(4) Accessing your home page in the client browser
http://www.benet.com/~usera/
http://www.benet.com/~userb/
########### Split Line using Awstats Analysis Web Log Information #######
Awstats Related directories and file lists:
-----------------------------------------------------------------------
Configuration file storage directory:/etc/awstats
Example of Web site configuration file:/etc/awstats/awstats.localhost.localdomain.conf
Example of Web site configuration file:/etc/awstats/awstats.model.conf
Home directory:/usr/share/awstats
Language directory:/usr/share/awstats/lang
Awstats Tools Catalog:/usr/share/awstats/tools
Default Awstats root directory:/usr/share/awstats/wwwroot
/var/lib/awstats
/etc/cron.hourly/awstats
/etc/httpd/conf.d/awstats.conf
------------------------------------------------------------------------
(1) Copy the Awstats package to the current Web server
[[email protected] tool]# ls
Awstats-6.9.tar.gz
(2) Unzip and release the Awstats software package and install
[[Email protected] tool]# tar zxvf awstats-6.9.tar.gz-c/usr/local//Unpack package to/usr/local directory
[[Email protected] local]# MV Awstats-6.9/awstats//Change the name of the package
[Email protected] local]# cd/usr/local/awstats/tools/
[[email protected] tools]#./awstats_configure.pl//Execute installation Script
----Set the path to the Apache Master profile httpd.conf
/etc/httpd/conf/httpd.conf
----Create a Awstats configuration file
Y
----Define the name of the target site for log analysis
Www.benet.com
----Define the Awstats configuration file directory (default is/etc/awstats)
Direct return
----Add Cron Scheduled Tasks (where the script cannot be added automatically and needs to be added manually by the user)
Direct return
----press ENTER to exit the setup script
(3) Modify the awstats.www.benet.com script
cd/etc/awstats/
VI awstats.www.benet.com.conf
Modify:
Logfile= "/var/log/httpd/access_log"
(4) Create a database storage directory and update the database
Perl/usr/local/awstats/wwwroot/cgi-bin/awstats.pl-update-config=www.benet.com
(5) Set Cron Schedule task to run Log Parser regularly
[Email protected] awstats]# CRONTAB-E
* */3 * * * perl/usr/local/awstats/wwwroot/cgi-bin/awstats.pl-update-config=wwww.benet.com
[Email protected] awstats]# service Crond restart
(6) View the analysis report in the Web browser
Http://www.benet.com/awstats/awstats.pl?config=www.benet.com
Each time you access an input URL that is too long, create a Web page to implement the jump
The code is as follows:
This can be accessed through the http://www.benet.com/aw.html!
########## Split Line implementing Apache the access control #####
(1) Implementation of user-based access control
Check the Apache Master Profile httpd.conf to confirm that the module for Basic authentication and digest authentication has been compiled
LoadModule Auth_basic_module modules/mod_auth_basic.so
LoadModule Auth_digest_module modules/mod_auth_digest.so
(2) Modify the main configuration file httpd.conf to achieve access control to the Awstats directory area
<directory "/usr/local/awstats/wwwroot" >
Options None
AllowOverride None
Order Allow,deny
Allow from all
AuthName "AWSTATS"
AuthType Basic
authuserfile/etc/httpd/conf/.htpasswd
Require Valid-user
</Directory>
(3) Create storage authentication user account and password file
[Email protected]/]# Useradd Awuser
[Email protected]/]# htpasswd-c/etc/httpd/conf/.htpasswd awuser
(4) Restart httpd service
Service httpd Restart
(5) Login test on client
Error! The hyperlink reference is not valid.