Apache server configuration overview (6)

Source: Internet
Author: User
Article Title: Apache server configuration overview (6 ). Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
During connection, the server can only obtain the IP address of the client. If you want to obtain the host name of the client for logging and providing it to CGI programs, you need to use the HostnameLookups option, 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, macro definitions starting with % are used to record different contents.
  
If the file specified by these parameters uses a relative path, it is the path relative to ServerRoot.
  
ServerSignature On
  
In some cases, for example, when the requested webpage does not exist, the server will generate an error document. By default, 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, so they can set this parameter to Off or Email, and the last line will be replaced with an 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 Common Document will be queried in DocumentRoot. However, the Alias-defined path will be directly mapped to the corresponding directory, instead of querying under DocumentRoot. Therefore, Alias can be used to map the paths of some public files. For example, it saves the icons paths of common icons. In this way, in addition to using symbolic connections, directories outside the document root directory (DocumentRoot) 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". 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.
Related Article

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.