Apache server configuration overview (3)

Source: Internet
Author: User
Apache server configuration overview (3)-Linux Enterprise Application-Linux server application information. See the following for details. Normally, the server can only obtain the IP address of the client.

Host Name for logging and providing it to CGI programs. You need to use this HostnameLookups option and set it to On to enable the DNS lookup function. However, this causes the server to perform DNS queries for each customer request, increasing system overhead and slowing down the response. Therefore, this option is disabled by default. After the option is disabled, the server will not obtain the host name of the client, but can only use IP addresses to record the client.


ErrorLog/var/log/httpd-error.log

LogLevel warn

LogFormat "% h % l % u % t" % r "%> s % B" % {Referer} I "" % {User-Agent} "" combined

LogFormat "% h % l % u % t" % r "%> s % B" common

LogFormat "% {Referer} I-> % U" referer

LogFormat "% {User-agent} I" agent

# CustomLog/var/log/httpd-access.log common

# CustomLog/var/log/httpd-referer.log referer

# CustomLog/var/log/httpd-agent.log agent

CustomLog/var/log/httpd-access.log combined


The system log format is defined here. For server error records, ErrorLog and LogLevel define different error log files and their recorded content.

For system access logs, the CustomLog parameter is used by default to define the log location, and the combined parameter is used by default to specify to put all access logs in one file, however, you can also store different types of access logs in different log records by specifying different record types in CustomLog. Common indicates the access record of a single page request, and referer indicates the reference record of each page. The number of requests contained in a page can be seen, and agent indicates the type record of the client, obviously, you can comment out the existing configuration lines defined by combined, and use common, referer, and agent as the CustomLog parameters to specify log records for different types of logs.

Obviously, LogFormat is used to define different types of logs for recording. Here

The macro definition starting with % is used to record different contents.

If the files specified by these parameters use relative paths

Path.


ServerSignature On

In some cases, for example, when the requested webpage does not exist, the server will generate an error document,

By default, because the ServerSignature option is enabled, the last line of the error document contains the server name, Apache version, and other information. Some administrators prefer not to display this information externally.

You can set this parameter to Off or Email. The last line will be replaced with the Email prompt for ServerAdmin.


Alias/icons/"/www/icons /"

Options Indexes MultiViews

AllowOverride None

Order allow, deny

Allow from all


The Alias parameter is used to directly map the URL to the real location in the Server File System.

The document will be queried in document. oot. However, the path defined by Alias will be mapped directly to

Directory instead of under document. oot. Therefore, Alias can be used to map some

Public file path. For example, the icons path of common icons is saved. In this way, in addition to using symbolic connections, directories outside the document root directory (document. oot) can also be accessed by using Alias ing.

After defining the ing path, you must use the Directory statement to set access restrictions.


ScriptAlias/cgi-bin/"/www/cgi-bin /"

AllowOverride None

Options None

Order allow, deny

Allow from all

ScriptAlias is also used for URL path ing, but unlike Alias, scriptAlias is used to map the path of CGI programs. All files in this path are defined as CGI programs, execute them to get the results, instead of directly returning the content by the server. By default, the CGI program uses the cgi-bin directory as the virtual path.


# Redirect old-URI new-URL

The Redirect parameter is used to override the URL. When the browser accesses a nonexistent resource on the server, the server returns a new URL to the browser, telling the browser to obtain the resource from the URL. This is mainly used for files originally stored on the server. After the location is changed, it is expected to be accessible using the old URL to maintain compatibility with the previous URL.


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. Fig. 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

AddIcon/icons/p.gif. pl. py

AddIcon/icons/f.gif.

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 README

AddIcon/icons/folder.gif ^ DIRECTORY ^

AddIcon/icons/blank.gif ^ BLANKICON ^

DefaultIcon/icons/unknown.gif

# AddDescription "GZIP compressed document. quot;. gz

# AddDescription "tar archive". tar

# AddDescription "GZIP compressed tar archive". tgz

ReadmeName README

HeaderName HEADER

IndexIgnore .?? **~ * # HEADER * README * rcs cvs *, v *, t


When the URL of an HTTP request is a directory, the server returns the index file in this directory. However, if the default index file does not exist in a directory and the server permits the display of the directory file list, the list of files in this directory is displayed, to make the file list understandable, not just a simple list, you need the preceding settings parameters.
If the IndexOptions FancyIndexing option is used, the directory columns generated by the server can be used.

The table references various icons for different types of documents. Which file uses the icon

The following AddIconByEncoding, AddIconByType, and AddIcon are defined to determine which icons to use based on the MIME encoding, type, and file suffix. If you cannot determine the icon used in the document, use the default icon defined by DefaultIcon.

Similarly, AddDescription can be used to add different descriptions for different types of documents. And,

The server is still in the directory and queries the files defined by ReadmeName and HeaderName (automatically added.

HTML extension. If not found, use the suffix .txt to search.) if these files are found,

The contents of these files are first displayed before the file list, so that the normal directory list has a larger

Understanding.

IndexIgnore allows the server to ignore the corresponding files when listing the files.

To define the file name.


AddEncoding x-compress Z

AddEncoding x-gzip gz

AddEncoding is used to tell the compressed MIME type, so that the browser can perform the decompression operation.


AddLanguage en. en

AddLanguage fr. fr

AddLanguage de. de

AddLanguage da. da

AddLanguage el. el

AddLanguage it. it

LanguagePriority en fr de


An HTML document can be used to prepare multiple languages at the same time. For example, it can be used for file1.html documents.

For different versions such as file1.html.en1_file1.html. fr, each language suffix must be defined using AddLanguage. In this way, the server can negotiate with the browser to send different language versions for customers in different countries. The Semantic agepriority defines the priority levels of different languages, so that when the browser does not have special requirements, the requests for file1.html are returned in different languages in sequence.

There are not many practical applications of this internationalization capability.

# AddType application/x-httpd-php. phtml

# AddType application/x-httpd-php-source. phps

The AddType parameter can specify the MIME type for a file with a specific suffix. The settings here will overwrite the settings in mime. types.


# AddHandler cgi-script. cgi

AddHandler is used to specify a non-static processing type, used to define a document as a non-static file

File type, which must be processed before returning the processing result to the browser. For example, if the setting in the above comment is to set the file ending with. cgi to the cgi-script type, the server will start this CGI program for processing. If you need to execute the CGI program outside the path defined by Aliasscript, you need to use this parameter for setting. Then, the file ending with. cgi will be executed as a CGI program.


The CGI program must be allowed in the configuration file,. htaccess in this directory, and. htaccess in its parent directory. This must be set through the Options ExecCGI parameter.


# AddType text/html. shtml

# AddHandler server-parsed. shtml

Another type of dynamic processing is server-parsed. The server analyzes the tags in the webpage in advance and changes the tags to the correct HTML tags. Because server-parsed needs to process text/html documents, the corresponding .shtml must be of the text/html type.

However, to support SSI, you must first in the configuration file (or. in htaccess), the Options using des allows the documents in this directory to be of the SSI type, or use Options using desnoexec to execute a common SSI flag, but do not execute external programs referenced in it.


Another way to specify the server-parsed type is to use the XBitBack setting option. If XBitHack is set to On, the server will check all text/HTML documents (documents suffixed with .html ), if the file property has the execution bit "x", the server considers it as a server analysis document and needs to be processed by the server. We recommend that you use AddHandler to set the XBitBack to Off, because XBitBack can be used to perform additional checks on all HTML documents, reducing efficiency.


# AddHandler send-as-is asis

# AddHandler imap-file map

# AddHandler type-map var

The AddHandler mentioned above is used to support the asis, map, and var processing capabilities of the Apache server.

.


# Action media/type/cgi-script/location

# Action handler-name/cgi-script/location

Because Apache provides limited processing functions internally, you can use Action to define the server.

A program is a dynamic file type that can be processed. These external programs are the same as the Standard CGI program. They process the input data and then output results of different MIME types. For example, to define an operation that executes wri2txt for the special suffix wri and then returns the result, you can use:


Action windows-writer/bin/wri2txt

AddHandler windows-writer wri

Furthermore, you can directly use Action to define a pre-processing operation for a MIME type.

You need to set the Action parameter in the first format in the example. In this way, no additional AddHandler is required to associate the processing operation with the file suffix. Instead, Action is used to directly process MIME-type files. However, if the document suffix does not have a formal MIME type, you must first define a MIME type.


# MetaDir. web

# MetaSuffix. meta

Meta information is sent to the client browser in advance before the document is sent to the customer. Therefore

The browser can access the Meta information through the HEAD request without actually returning all the document data through GET. The server usually sends some standard HTTP header information to the browser. To add additional information, you need to use MetaDir to define the directory where Meta data is stored, metaS uffix is used to specify the file suffix that contains Meta data.


# Errordocument. nbsp500 "The server made a boo.

# Errordocument. nbsp404/missing.html

# Errordocument. nbsp404/cgi-bin/missing_handler.pl

# Errordocument. nbsp402

Http://some.other _ server.com/subscription_info.html

If the requested webpage does not exist or you do not have the access permission

Generate an error code and respond to a webpage with an incorrect logo in the client browser.

Errordocument. used to set the content in the client browser that should be responded to when an error occurs, Errordocument. the first parameter is the error serial number, and the second parameter is the response data. It can be a simple text, local webpage, local CGI program, or a webpage on a remote host.


BrowserMatch "Mozilla/2" nokeepalive

BrowserMatch "MSIE 4.0b2;" nokeepalive downgrade-1.0 force-response-1.0

BrowserMatch "RealPlayer 4.0" force-response-1.0

BrowserMatch "Java/1.0" force-response-1.0

BrowserMatch & quot; JDK/1.0 & quot; force-response-1.0

The BrowserMatch command is used to set special parameters for a specific client program to ensure that

Browser compatibility, and support new features of the new browser.


#

# SetHandler server-status

# Order deny, allow

# Deny from all

# Allow from. your_domain.com

#

#

# SetHandler server-info

# Order deny, allow

# Deny from all

# Allow from. your_domain.com

#

#

# Deny from all

# Errordocument. nbsp403 http://phf.apache.org/phf_abuse_log.cgi

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.