Master teaches you the configuration and management of Apache server

  

WWW service

1, www (World wide web, global information network), is built on the Internet, with WEB services as a form of expression A logical network.

2, WEB service implementation program: MS IIS, Apache, SunONE, NCSA httpd

Install Apache

1, installation package structure

httpd- 2.2.3-6.el5.i386.rpm Main Program

httpd-manual-2.2.3-6.el5.i386.rpm Apache Manual

httpd-devel-2.2.3- 6.el5.i386.rpm Development Library

system-config-httpd-1.3.3.1-1.el5.noarch.rpm Graphic Configuration Tool

2. Start Apache Test Installation: Service Name Httpd

3, configuration file /etc/httpd/conf/httpd.conf

Apache service configuration and management

First, the basic configuration of Apache service

1, configuration file /etc/httpd/conf/httpd.conf

Structure: Section 1: Global Environment

Section 2: 'Main' server configuration (main server Configuration)

Section 3: Virtual Hosts

Second, Apache basic configuration

1, set Apache's home directory

279 DocumentRoot "/var/www/html"

Do cumentRoot "Apache home directory absolute path"

2, set Apache home page file

390 DirectoryIndex index.html index.html.var

DirectoryIndex order 1 file order 2 File... Sequence n file

3. Set the listening port of the Apache service

134 Listen 80 Listen to port 80 of all IPs on this machine

Listen IP : Port number to listen to the specific port of the specific IP of the machine

In Apache, multiple Listen commands can be used to implement flexible configuration of multiple hosts and multiple ports.

4, set the relative root directory of Apache:

a, the relative root directory is the storage location of the Aapache program file, including configuration files and log files.

b, 57 ServerRoot "/etc/httpd"

5, set the Apache log file:

a, the type of log: error log

Access log

b, error log: 471 ErrorLog logs/error_log

ErrotLog Error log file name

c, access log: 513 CustomLog logs/access_log combined

CustomLog Access Log File Name Access Log Format

Access Log Format: common (standard format, recognized by most log analysis tools)

combined (common extension)
>

The log format is defined by the 484 LogFormat command.

6. The administrator address is set, and the notification address when Apache fails.

250 ServerAdmin root@localhost

7. Set the host name of the host where the Apache service is located: Apache will resolve the host name to DNS when it starts.

263 ServerName www.itatpro.com :80

ServerName Host FQDN: Port Number

ServerName IP: Port Number

III. Setting User Home Directory Permissions

304 Directory "/var /www/html"

Directory "User Home Directory"

318 Options Indexes FollowSymLinks MultiViews

Options Allow Directory Browsing to Allow Multiple Views

-Indexes Directory browsing is not allowed

Multiple views Apache will automatically match similar content backhaul clients, supporting the use of

connection files.

325 AllowOverride None (disallow access control using .htaccess files in each directory)

330 Order allow,deny (access control)

331 Allow from all < Br>

Order Allow, Forbidden

Allow from All

Order Priority 2, Priority 1

allow from IP Allowed Access

deny from IP address that is forbidden to access

333 /Directory
Fourth, create a virtual directory

1, virtual directory: is the expansion of the main directory. Virtual directories provide flexible disk space configuration.

2, add virtual directory:

Alias ​​/virtual directory name /"virtual directory location"

Directory "virtual directory location"

541 Options Indexes MultiViews

542 AllowOverride None

543 Order allow,deny

544 Allow from all

545 /Directory

3, absolute reference

Alias ​​/virtual directory name (/) "/virtual directory actual location (/)"

Five, access control

1, user authentication

a, create a password file and add a security account

#htpasswd -c /password file storage location security account name

-c create a password file

b. Configure user authentication (directory permission setting field)

AuthType Basic (user authentication type basic authentication)

AuthName "This is a security Site, Please Login:" (user authentication domain content)

AuthUserFile /etc/httpd/passwd01 (Location of User Password File)

Require user Root tom (users allowed to access)

VI. Virtual Hosts

1. IP-based virtual host

a. Determine the IP address of the host:

New virtual interface: #ifconfig eth0:1 IP address

b. Create IP-based virtual host

VirtualHost 192.168.16.252

ServerName 192.168.16.252:80 Set host Name

ServerAdmin [email protected] Admin Email Address

DocumentRoot "/www/itat" Home Directory

DirectoryIndex index.html Home File

Errorlog logs/itat/error_log Error Log

Customlog logs/itat/access_log common Access Log

AuthType Basic

AuthName "This is a security Site,Please Login:" < Br>

AuthUserFile /etc/httpd/passwd01

Require user root tom

/VirtualHost

2, Port-based virtual host

VirtualHost *:8081 (* indicates all IP addresses of this machine)

ServerName 192.168.16.254:8081

......

/VirtualHost

3. Multi-host-based virtual host (all sites should be included in the virtual host settings)

a, Create a DNS resolution structure

b. Create a host-based virtual host

Example: NameVirtualHost 192.168.16.254 (Set the IP shared by different host headers)

VirtualHost www. Itat.com (the first virtual host is the default virtual host, taking all access to this

ServerName www.itat.com:80 Apache non-designated host header)

ServerAdmin root@itat. Com

DocumentRoot "/www/itat"

DirectoryIndex index.html

Errorlog logs/itat/error_log

Customlog logs/itat/access_log common < Br>

/VirtualHost

VirtualHost www.baidu.com

ServerName www.baidu.com:80

ServerAdmin [email protected]

DocumentRoot "/www/baidu"

DirectoryIndex index.html

Errorlog logs/baidu/error_log

Customlog logs /baidu /access_log common

/VirtualHost

Copyright © Windows knowledge All Rights Reserved