The HTTP service experiment of the Beginner Linux Network Service

Source: Internet
Author: User


Experimental topology:

Linux Client

-----RHEL5.9 (Vmnet1)----------(VMNET1)

Win7 Client


Experiment one: View the default HTTP configuration

Find the default Red Hat Welcome page

(/etc/httpd/conf/httpd.conf---->include---->/ETC/HTTPD/CONF.D----> welcome.conf---->/var/www/error/ noindex.html)

Prerequisites:

1. Configure IP

[[email protected] ~]# Cat/etc/sysconfig/network-scripts/ifcfg-eth0//set NIC parameters

# Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)

Device=eth0

Bootproto=static//static manually assigned address

Onboot=yes

Hwaddr=00:0c:29:5d:a8:80

ipaddr=192.168.10.253

netmask=255.255.255.0

2. Configure Host Name

[[email protected] ~]# cat/etc/sysconfig/network//View host name

Networking=yes

Networking_ipv6=yes

Hostname=web01.tarena.com

3. Modify the Hosts file

[[email protected] ~]# cat/etc/hosts//Modify the host file for address translation

# don't remove the following line, or various programs

# that require network functionality would fail.

127.0.0.1 localhost.localdomain localhost

:: 1 localhost6.localdomain6 Localhost6

192.168.10.253 web01.tarena.com WEB01

[[Email protected] ~]# Service Network restart//Restart network services

[[email protected] ~]# chkconfig Network on//Set up Web service boot

4, the installation of the package

[[email protected] ~]# rpm-q httpd//query httpd package with or without installation

Package httpd are not installed

[[email protected] ~]# yum-y install httpd//Use Yum Library installation httpd

5. Start the service

[[Email protected] ~]# service httpd restart//start httpd Services

[[email protected] ~]# chkconfig httpd on//Set HTTPD service boot from




Test two: Configuration of the basic HTTP server

Web server domain name: www.tarena.com

The default homepage includes: index.html, index.php

Turn on Keep connected

Verify that the default httpd supports PHP

Web site with teacher-provided test_web.zip test


Server operation:

1. Back up the main configuration file

[[email protected] ~]# cd/etc/httpd/conf//Enter the Master profile directory

[[email protected] conf]# CP httpd.conf Httpd.conf.bak//Backup profile to prevent configuration errors after recovery

2. Modify the master configuration file

[[email protected] ~]# vim/etc/httpd/conf/httpd.conf//Edit Master Profile

...

KeepAlive on//Keep connected

...

265 ServerName www.tarena.com:80//web Server domain name

...

391 directoryindex index.html index.php//default Home

...

3. Start the service

[[Email protected] ~]# service httpd restart//Restart services

[Email protected] ~]# cd/root/desktop/

[[email protected] desktop]# Unzip Test_web.zip//Unzip test file

[[Email protected] desktop]# mv jiajutiyan/*/var/www/html///Move the test site to the default working directory

4. Write Test PHP page

[Email protected] ~]# vim/var/www/html/test.php

<?php

Phpinfo ();

?>


Test:

1. In the client Hosts file, specify

192.168.10.253www.tarena.comwww

2. Open the browser

Http://www.tarena.com

http://www.tarena.com/test.php


3. Linux Client Authentication

IP address settings and the host File Settings reference server configuration,

[Email protected] ~]# cat/etc/hosts

# don't remove the following line, or various programs

# that require network functionality would fail.

127.0.0.1 localhost.localdomain localhost

:: 1 localhost6.localdomain6 Localhost6

192.168.10.253 www.tarena.com www


Enter www.tarena.com in the browser the home page description of the test site has been set successfully

Access to PHP display file content, indicating that PHP is not supported by default

4. Win7 Client Authentication

1) manually set IP and server on the same network segment

2) Set up the Hosts file

C:\Windows\System32\drivers\etc\hosts//Modify host File

LocalHost name resolution is handled within DNS itself.

#127.0.0.1 localhost

#:: 1 localhost

192.168.10.253 www.tarena.com www


Browser Access www.tarena.com The home page description of the test site has been set successfully

Experiment three: Set only allow users with IP address 192.168.10.21 to access www.tarena.com

Set allow all users to access www.tarena.com/authdir/index.html

1. Edit the master configuration file


[[email protected] ~]# vim/etc/httpd/conf/httpd.conf//edit httpd Master Profile

...

306 <directory "/var/www/html" >//Site Directory

...

333 Order Allow,deny//define Control order

334 # Allow from all//comment off default allows all

335 Enable from 192.168.10.21//Add only allow this IP access

336 </Directory>

...


2. New Authdir site

[[email protected] ~]# Mkdir/var/www/html/authdir//New directory Authdir

[[email protected] ~]# echo "http://www.tarena.com/authdir/index.html" >/var/www/html/authdir/index.html//Output character to a Uthdir/index.html


[[email protected] ~]# vim/etc/httpd/conf/httpd.conf//Edit Master Profile

...

337 <Directory/var/www/html/authdir>

338 Order Allow,deny//Set Control order

339 Allow all users

340 </Directory>

[[Email protected] ~]# service httpd restart//restart HTTPD services

[[email protected] ~]# tail/var/log/httpd/error_log//Access errors can be viewed on the server log


Testing on different clients

1. Testing on Linux Clients

1) The Linux client IP address 192.168.10.20 cannot access www.tarena.com,

2) The browser address bar input www.tarena.com/authdir/index.html, you can access

2, in the Win7 client test (IP192.168.10.21)

1. Access to Www.tarena.com

2. Access to www.tarena.com/authdir/index.html



Test four: User Authorization for HTTP

Client Access Http://www.tarena.com/authdir need to enter username password Authentication


1. Modify the master configuration file

[[email protected] ~]# vim/etc/httpd/conf/httpd.conf//Edit Master Profile

...

337 <directory "/var/www/html/authdir" >//Catalogue

338 Order Allow,deny//control Order

339 Allow all users

340 AuthName "Please Input password!!"//certification field, pop-up window tips

341 AuthType Basic//authentication type

342 AuthUserFile "/etc/httpd/.vuser"//user Data file path

343 Require Valid-user//Designated authorized User

344 </Directory>

...

2. Create account password

[[email protected] ~]# htpasswd-c/etc/httpd/.vuser Admin//create Access User

New Password://Set Password

Re-type New Password://Verify Password

Adding Password for user admin

3. Start the service test

[[Email protected] ~]# service httpd restart//Restart services

Http://www.tarena.com/authdir

Customer and test:

Two different client access Www.tarena.com/authdir prompt to enter a user name password, enter the user name password normal access, indicating the success of the setup


Experiment five: HTTP directory aliases

Http://www.tarena.com/sina can be used to prevent the/var/www/html/sina.com/bbs of the Web page when the client accesses

1. Create a test Site

[[email protected] ~]# mkdir-p/var/www/html/sina.com/bbs//Create Site

[[email protected] ~]# vim/var/www/html/sina.com/bbs/index.html//edit page

<body>

</body>

2. Modify the master configuration file

[[email protected] ~]# vim/etc/httpd/conf/httpd.conf//Modify master configuration file

Alias/sina "/var/www/html/sina.com/bbs"//Global configuration Add alias statement

3. Start the service test

[[Email protected] ~]# service httpd restart//Restart services

Win7 Client test Access Http://www.tarena.com/sina Display this is bbs.sina.com test Page!!! Set success

Experiment Six:

See how the default HTTP usage process is managed

Change the default process management mode to worker mode

[[email protected] ~]# httpd-l//view default process management mode

Compiled in Modules:

Core.c

PREFORK.C//default is Prefork

Http_core.c

Mod_so.c

[[email protected] ~]# cd/usr/sbin///Enter the Sbin directory

[[Email protected] sbin]# mv httpd httpd.prefork//change HTTP name

[Email protected] sbin]# mv Httpd.worker httpd//rename Httpd.worker to httpd

[[Email protected] sbin]# service httpd restart//restart HTTP Services

[[email protected] sbin]# httpd-l//view process management mode

Compiled in Modules:

Core.c

WORKER.C//Set success for worker mode

Http_core.c

Mod_so.c


Test Seven:

Deploying Awstats Statistics HTTP access logs

1, install the software (the software has been copied to/USR/SRC)

[Email protected] ~]# cd/usr/src/

[[email protected] src]# TAR-ZXVF awstats-7.1.tar.gz-c/usr/local///Extract Files

[Email protected] src]# cd/usr/local/

[[Email protected] local]# MV Awstats-7.1/awstats//Move folder to local and rename

[Email protected] local]# CD awstats/tools/

[[email protected] tools]#./awstats_configure.pl//Run File

...

Config file path (' None ' to skip Web server Setup):

>/etc/httpd/conf/httpd.conf//Enter Apache's master configuration file

...

-----> need to create a new config file?

Do you want me to build a new AWStats Config/profile

File (required if first install) [y/n]? Y//Generate Awstats configuration file

...

Your Web site, virtual server or profile name:

> www.tarena.com//Enter your Web server name

...

Default:/etc/awstats

Directory path to store config file (s) (Enter for default):

>

...

/usr/local/awstats/tools/awstats_updateall.pl now

Press ENTER to continue ...

...

Press ENTER to finish ...

2. Modify the master configuration file

[[email protected] tools] #vim/etc/awstats/awstats.www.tarena.com.conf//Edit Awstats Master Profile

...

Wuyi logfile= "/var/log/httpd/access_log"//modify log file path

[[email protected] tools]# mkdir/var/lib/awstats//Create Folder

3. Import the log file into Awstats

[[email protected] tools]#./awstats_updateall.pl Now//Run file import log

[[email protected] tools]# crontab-l//view cycle tasks

*/5 * * * * */usr/local/awstats/tools/awstats_updateall.pl now//run every 5 minutes

[[Email protected] tools]# service Crond restart//Restart Cycle Scheduled task service

[Email protected] tools]# chkconfig Crond on

4. Verification:

Visit the following URLs:

Http://www.tarena.com/awstats/awstats.pl?config=www.tarena.com can see website statistics


Add:

Web page jump function via HTML code

[Email protected] tools]# vim/var/www/html/awstats.html//Edit awstats.html

<body>

</body>

Verify:

Browser access http://www.tarena.com/awstats.html display statistics for set success


This article is from the "Forward Linux Notes" blog, so be sure to keep this source http://momodeqianxing.blog.51cto.com/9041985/1427092

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.