Apache master configuration file (configuration explanation)

xiaoxiao2021-03-05  29

Apache provides a variety of features for network administrators, including directory index, directory alias, content negotiation, configurable HTTP error report, CGI program's setuid execution, child process resource management, server-side image map, rewrite URL, URL spell check and online manual MAN, etc. That is, if you have successfully installed Apache on Linux Server, your computer will also turn around with Apache, becoming a veritable web server, which is indeed exciting.

In the Internet era, the release of the external homepage has become an important means of establishing the company's image, and the internal home page has become the main way of company management. However, if you want to implement these features, you should first configure our Linux Server to become a powerful web server. This chapter will detail how to configure the APACHE server. I hope that all the colleagues can achieve the purpose of reading this film to reach the theoretical practice, and quickly become an excellent network administrator in a short period of time.

1.2 required resources

1.2.1 required package

RedHat6.2 server installation

1.2.2 required configuration files

/etc/httpd/conf/httpd.conf system comes with, administrator configuration

/etc/httpd/conf/access.conf system comes with it, no need to modify

/etc/httpd/conf/srm.conf system comes with it, no need to modify

1.3 configuration plan

/etc/httpd/conf/httpd.conf

Description: Apache master configuration file

Source File:

Servertype Standalone

# Define the WebServer's booting method for Standalone to enhance its timely response to large number of access.

Serverroot "/ etc / httpd"

# Specify the directory containing the HTTPD server file

Lockfile /var/lock/httpd.lock

Pidfile /var/run/httpd.pid

ScoreboardFile /var/run/httpd.scoreboard

TIMEOUT 300

# Response timeout, unit is second

Keepalive ON

# Allow users to establish permanent connection

MaxkeepaliveRequests 100

KeepaliveTimeout 15

MinSpareServers 5

# Minimum of idle server processes to be reserved

MaxSpareServers 20

# The maximum value of the idle server process to be retained

STARTSERVERS 8

# The number of daemons when the system starts

MaxClients 150

# The maximum client number that can serve the service, which is greater than its part of its part is put into the request queue

MaxRequestSperChild 100

LOADMODULE vhost_alias_module modules / mod_vhost_alias.so

LOADMODULE ENV_MODULE MODULES / MOD_ENV.SO

LoadModule config_log_module modules / mod_log_config.so

LOADMODULE AGENT_LOG_MODULE MODULES / MOD_LOG_AGENT.SO

LOADMODULE REFERER_LOG_MODULE MODULES / MOD_LOG_REFERER.SO

LOADMODULE MIME_MODULE MODULES / MOD_MIME.SO

LoadModule Negotiation_Module Modules / MOD_NEGOTITION.SO

LoadModule Status_Module Modules / MOD_STATUS.SO

LOADMODULE INFO_MODULE MODULES / MOD_INFO.SOLOADMODULE INCLUDES_MODULE MODULES / MOD_INCLUDE.SO

LoadModule AutoIndex_Module Modules / MOD_AUTOINDEX.SO

LoadModule Dir_Module Modules / MOD_DIR.SO

LoadModule CGI_Module Modules / MOD_CGI.SO

LoadModule Asis_Module Modules / MOD_ASIS.SO

LoadModule IMAP_MODULE MODULES / MOD_IMAP.SO

LoadModule Action_Module Modules / MOD_A / AACTIONS.SO

LoadModule Userdir_Module Modules / MOD_USERDIR.SOSO

LoadModule Alias_Module Modules / MOD_ALIAS.SO

LoadModule Rewrite_Module Modules / MOD_rewrite.so

LoadModule Access_Module Modules / MOD_ACCESS.SO

LoadModule Auth_Module Modules / MOD_AUTH.SO

LOADMODULE Anon_AUTH_MODULE MODULES / MOD_AUTH_ANON.SO

LoadModule DB_AUTH_MODULE MODULES / MOD_AUTH_DB.SO

LoadModule Digest_Module Modules / MOD_Digest.so

LoadModule Proxy_Module Modules / LibProxy.so

LoadModule Expires_Module Modules / MOD_EXPIRES.SO

LoadModule Headers_Module Modules / MOD_HEADERS.SO

LoadModule Usertrack_Module Modules / MOD_USERTRACK.SO

LoadModule SetENVIF_MODULE MODULES / MOD_SETENVIF.SO

LoadModule Perl_Module Modules / Libperl.so

LoadModule PHP3_MODULE MODULES / LIBPHP3.SO

ClearModuleList

AddModule MOD_VHOST_ALIAS.C

AddModule MOD_ENV.C

AddModule MOD_LOG_CONFIG.C

AddModule MOD_LOG_AGENT.C

AddModule MOD_LOG_REFERER.C

AddModule MOD_MIME.C

AddModule MOD_NEGOTIATION.C

AddModule MOD_STATUS.C

AddModule MOD_INFO.C

AddModule MOD_INCLUDE.C

AddModule MOD_AUTOINDEX.C

AddModule MOD_DIR.C

AddModule MOD_CGI.C

AddModule MOD_ASIS.C

Addmodule MOD_IMAP.C

AddModule MOD_ACTIONS.C

#Addmodule mod_speling.c

AddModule MOD_USERDIR.C

AddModule MOD_ALIAS.C

AddModule MOD_REWRITE.C

AddModule MOD_ACCESS.C

AddModule MOD_AUTH.C

AddModule MOD_AUTH_ANON.C

AddModule MOD_AUTH_DB.CADDModule MOD_Digest.c

AddModule MOD_PROXY.C

AddModule MOD_EXPIRES.C

AddModule MOD_HEADERS.C

AddModule MOD_USERTRACK.C

AddModule MOD_SO.C

AddModule MOD_SETENVIF.C

AddModule MOD_PERL.C

AddModule MOD_PHP3.C

Port 80

# Define the port number of the TCP used by the server

User Nobody

Group nobody

# The above two lines are file permissions for new users assigned to httpd, for security considerations.

Their permissions are set to be the lowest.

ServerAdmin root@weboa.com.cn

# Set the mail address of the web administrator

ServerName Weboa

# Defining the client from the host name when reading data from the server, the default value

It is Localhost. When you first install Linux, you will always go wrong here.

Documentroot "/ home / weboa / jakarta-tomcat / webapps / weboa"

# Set the root directory of all Apache documents, for example, user

Http://www.weboa.com.cn/index.html Access request, Apache to it

Response is /Home/weboa/jakarta-tomcat/webapps/weboa/index.html

Options Followsymlinks

ALLOWOVERRIDE NONE

Options INDEXES INCLUDES FOLLOWSYMLINKS

ALLOWOVERRIDE NONE

ORDER ALOW, DENY

Allow from all # Allows everyone to access

Userdir public_html

DirectoryIndex index.html index.htm index.shtml index.cgi

# Set a variety of ways to successfully access the home page, to improve the fault tolerance of the system

AccessFileName .htaccess

ORDER ALOW, DENY

Deny from all

Usecanonicalname on

TypeSconfig /etc/mime.types

DefaultType Text / Plain

MimeMagicfile Share / Magic

Hostnamelookups off

ErrorLog / USR / httpd / log / error_log

Loglevel Warn

# Define those error types being recorded in the error log

Logformat "% H% L% u% T /"% r / "%> s% b /"% {referer} I / "/"% {user-agent} i / "combined

# All logFormats are used to define entries in the log

Logformat "% H% L% u% T /"% r / "%> s% B" CommON

Logformat "% {referer} i ->% u" Referer

Logformat "% {User-agent} i" Agent

Customlog / usr / httpd / log / access_log common

Serversignature ON

Alias ​​/ icons / "/ home / httpd / icons /"

# Define the correspondence between the virtual host directory and the system directory

Options Indexes MultiViews

ALLOWOVERRIDE NONEORDER ALLOW, DENY

ALLOW FROM ALL

Scriptalias / cgi-bin / "/ home / httpd / cgi-bin /"

# Define the CGI directory

ALLOWOVERRIDE NONE

Options Execcgi

ORDER ALOW, DENY

ALLOW FROM ALL

IndexOptions FancyIndexing

AddiconbyEncoding (CMP, / ICONS / Compressed.gif) X-Compress X-Gzip

AddiconByType (txt, / icons / text.gif) text / *

AddiconByType (IMG, / ICONS / Image2.gif) Image / *

AddiconByType (SND, / ICONS / SOUND2.GIF) AUDIO / *

AddiconBytype (VID, / ICONS / MOVIE.GIF) VIDEO / *

Addicon /icons/binary.gif .bin .exe

Addicon /icons/binhex.gif .hqx

Addicon /icons/tar.gif.tar

Addicon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv.

Addicon /icons/compressed.gif.z .z .tgz .gz .zip

Addicon /icons/a.gif.ps .ai .eps

Addicon /icons/Layout.gif .html .shtml .htm .pdf

Addicon /icons/text.gif.txt

Addicon /icons/c.gif .c .c

Addicon /icons/p.gif.pl .py

Addicon /icons/f.gif .for

Addicon /icons/dvi.gif.dvi

Addicon /icons/uuencoded.gif .uu

Addicon /icons/script.gif .conf .sh .shar .csh .ksh .tcl

Addicon /icons/tex.gif .tex

Addicon /icons/bomb.gif core

Addicon /icons/back.gif ..

Addicon /icons/hand.right.gif ready

Addicon /icons/folder.gif ^^ Directory ^^

Addicon /icons/blank.gif ^^ blankicon ^^

Defaulticon /icons/unknown.gif

ReadMename Readme

Headername header

Addencoding X-Compress Z

Addencoding X-Gzip GZ TGZ

Addilaguage en .en

AddLanguage Fr .fr

AddLanguage de .de

AddLanguage da .da

AddLanguage El .l.

AddLanguage It .it

LanguagePriority En fr de

AddType Application / X-httpd-php3 .php3

AddType Application / X-httpd-php3-source .phps

AddType Application / X-httpd-php .phtml

AddType Application / X-tar .tgz

Addtype text / html .shtml

AddHndler Server-Parsed .shtml

AddHandler Imap-File Map

Browsermatch "RealPlayer 4 / .0" Force-Response-1.0Browsermatch "Java / 1 / .0" Force-Response-1.0

Browsermatch "JDK / 1 / .0" Force-Response-1.0

Alias ​​/ perl / / home / httpd / perl /

SetHandler Perl-script

Perlhandler Apache :: Registry

Options Execcgi

Alias ​​/ Doc / / USR / DOC /

ORDER DENY, ALOW

Deny from all

ALLOW from Localhost

Options Indexes FollowSymlinks

INCLUDE / Etc/httpd/conf/tomcat-apache.conf

Alias ​​/ Netcard "/ Home / WebA / Jakarta-Tomcat / WebApps / Weboa / Net_Card"

Options Indexes FollowSymlinks

ALLOW FROM ALL

Cachesize 5

# Define the size of the cache area, in KB. Can be set as needed and hard disk space size

Cachegcinterval 4

# Check the cache every 4 hours, and delete the file more than Cachesize

CacheMaxExpire 24

#Http files are maintained for up to 24 hours

CacheLastModifiedFactor 0.1

# Define the HTTP file failure period, the default is 0.1, meaning that the failure period = time X of the last revision, such as 5 hours from the last revised time, then the expiration date is 5x0.1 = 0.5 hours

CachedefaultExpire 1

# This instruction provides a default time (hour) to destroy the cache file, which is unknown to the last change time of these files. The cachemaxexpire command does not overwrite this setting

## The following is how to log in to the control for a directory ## Add the following in /etc/httpd/conf/httpd.conf:

Alias ​​/ WEBOA / "/ home / weboa /"

Options Indexes MultiViews

ALLOWOVERRIDE AUTHCONFIG

ORDER ALOW, DENY

ALLOW FROM ALL

Built .htaccess file in the / home / weboa directory

Authname "Shared Files"

Authtype Basic

Authorfile / etc / httpd / conf / passwd

Require Valid-User

Execute a command to generate an authentication file in the / etc / httpd / conf directory

Htpasswd -c THJ THJ # Create a authentication file and the first name and password

Htpasswd Weboa Weboa # Add other usernames and passwords

### The following is a method of implementing a virtual host ###

Need to add the following in /etc/httpd/conf/httpd.conf:

Alias ​​/ WebAdmin / "/ Home / Weboa / WebAdmin / HTML /"

Options Indexes MultiViews

ALLOWOVERRIDE NONE

ORDER ALOW, DENY

ALLOW FROM ALL

NameVirtualHost 192.168.0.1 # DNS server for virtual domain name

ServerAdmin root@weboa.com.cn # NMS email address

DocumentRoot / Home / Weboa / WebAdmin / HTML / # server page directory servername webadmin.weboa.com.cn # server name

Need to add content added to /VAR/NAMED/Name2ip.conf:

WebAdmin in A 192.168.0.1

1.4 Test and Management Measures

1.4.1 test method

Whenever the administrator changes the setting of Apache, the /etc/rc.d/init.d/httpd restart should make changes to take effect.

1.4.2 management method

Apache offers a large number of log files. When Apache is wrong, the administrator can diagnose according to the path to the ErrorLog defined in htppd.conf. The specific method is:

Tail -f / var / log / httpd / apache / error_log

转载请注明原文地址:https://www.9cbs.com/read-36873.html

New Post(0)