Introduction: This is a detailed page about the Apache configuration file httpd. conf [transfer] (2). It introduces the related knowledge, skills, experience, and some PHP source code.
Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 325363 'rolling = 'no'>
# Extendedstatus on <br>
The Apache server can report its running status through special HTTP requests. <br>
The extendedstatus parameter allows the server to report more comprehensive running status information. <Br>
Master Server Settings <br>
The Apache server requires various settings to define its own use of various parameters to provide web services. When a VM is used, in addition to the settings covered in the definition items of the VM (some settings must be redefined), the settings here are also the default settings of the VM. <Br>
Port 80 <br>
Port defines the port used by the httpd daemon in standalone mode. The standard port is 80. This option is only applicable Cube For inetd-enabled servers, define which port to use in inetd. conf. <Br>
Root permission is required to use port 80 in Unix. For security reasons, some administrators believe that the httpd server cannot have security vulnerabilities. Therefore, they prefer to use the permissions of common users to start the server, in this way, port 80 and other ports smaller than 1024 cannot be used, but port greater than 1024 must be used to start httpd. Generally, port 8000 or 8080 is also a common port. The Apache httpd server can be run as a common user after Port 80 is opened with the root permission. This reduces the risk and thus does not need to be considered. However, if you want to install and configure your own WWW server, you have to use a port greater than 1024. <Br>
User nobody <br>
Group nogroup <br>
User and group configurations are the security guarantee of Apache. After Apache opens the port, it sets itself as the user and group permissions set for these two options to run, this reduces the risk of servers. This option is only used in standalone mode. The inetd mode specifies the user that runs Apache in inetd. conf. Because the server must perform the setuid () operation to change the identity, the initial process should have root permissions. If a non-root user is used to start aapche, this configuration will not work. <Br>
The default value is nobody and nogroup. This user and group do not have files in the system, which ensures that the server itself and the CGI process started by it do not have the permission to change the file system. In some cases, for example, to run CGI and Unix interaction, you also need to have the server access the files on the server. If nobody and nogroup are still used, the nobody file will appear in the system, which is detrimental to system security, because other Program It also performs certain operations with the nobody and nogroup permissions, and may access the files owned by these nobodies, resulting in security problems. Generally, you need to set a specific user and group for the Web service, and change the user and group settings here. <Br>
Serveradmin you@your.address <br>
Only serveradmin should be changed in the configuration file. This item is used to configure the email address of the administrator of the WWW server. This will be returned to the browser when an HTTP service error occurs, this allows the Web user to contact the Administrator to report errors. Traditionally, webmaster on the server is used as the administrator of the WWW server. Through the alias mechanism of the mail server, emails sent to webmaster are sent to the real web administrator. <Br>
# Servername new. Host. Name <br>
By default, you do not need to specify this servername parameter. The server automatically resolves the problem by name. <br>
The parsing process is used to obtain your own name, but if there is a problem with server name resolution (usually reverse resolution is not available <br>
Correct), or there is no formal DNS name, you can also specify an IP address here. When servername is set <br>
When the configuration is incorrect, the server cannot start normally. <Br>
Generally, a Web server can have multiple names. The client browser can use all these names or IP addresses to access the server. However, if no virtual host is defined, the server always responds to the browser with its own official name. Servername defines the formal name recognized by the Web server. For example, if the name of a server (a type is defined in DNS) is exmaple.org.cn, at the same time, an alias (cname record) is also defined as www.exmaple.org.cn for convenience of memory, so the name automatically parsed by Apache is example.org.cn, so no matter which name the client browser uses to send requests, the server always tells the customer that the program is example.org.cn. Although this generally does not cause any problems, considering that the server may be migrated to another computer one day, the Migration task is completed only by changing the WWW alias configuration in DNS, therefore, if you do not want to use Linux to record the address of the server in their bookmarks, you must use servername to re-specify the official name of the server. <Br>
DocumentRoot & quot;/www/& quot; <br>
DocumentRoot defines the path for storing Hypertext files released by the server. The Ur l requested by the client program is mapped to the webpage files under this directory. Sub-directories under this directory, and use <br>
The file and directory indicated by the symbolic connection can be accessed by the browser, but the same relative directory name must be used on the URL. <Br>
Note: although the symbolic connection is logically located under the root document directory, it can actually be located in a computer <br>
Therefore, the client program can access directories outside the root document directory.
Increased flexibility while reducing security. Apache provides the followsymlinks option in Directory Access Control to enable or disable the feature that supports symbolic connections. <Br>
Options followsymlinks <br>
AllowOverride none <br>
The Apache server can control document access to directories. However, the access control can be implemented through two methods: <br>
In the httpd. conf (or access. conf) file. <br>
Another method is to set the access control file under each directory, usually the access control file <br>
The name is. htaccess. Although both methods can be used to control browser access, the configuration file method requires that the httpd daemon be restarted after each change, which is not flexible, therefore, it is mainly used to configure the overall security control policy of the server system and use. it is more flexible and convenient to set access control for specific directories in the htaccess file. <Br>
The directory statement is used to define the access restriction of a directory. here we can see its standard syntax, which defines the access restriction for a directory. In the preceding example, this setting is for the root directory of the system. The followsymlinks option is set to allow symbolic connections, and use AllowOverride none to indicate that the access control file in this directory is not allowed to change the configuration here, which means that you do not need to view the corresponding access control file in this directory. <Br>
Because Apache's access control settings for a directory can be inherited by the next-level directory, <br>
The setting of the root directory affects its sub-directory. Note that because AllowOverride none is set, <br>
The Apache server does not need to view the access control file in the root directory or the following levels of contents <br>
Until a directory is specified in httpd. conf (or access. conf). <br>
Allows alloworride to view access control files. Because Apache uses the Inheritance Method for directory access control, if you can view the access control file from the root directory, Apache must view the access control file at the first level, this will affect system performance. By default, the root directory feature is disabled, which enables Apache to search down from the specific directory specified in httpd. conf, reducing the search level and increasing system performance. Therefore, setting AllowOverride none in the system root directory is not only helpful to system security, but also beneficial to system performance. <Br>
Options indexes followsymlinks <br>
AllowOverride none <br>
Order allow, deny <br>
Allow from all <br>
Here, we define access settings for directories in the system's external release documents, and set different AllowOverride options to define the relationship between directory settings in the configuration file and security control files in the user directory, the options option defines the features of this directory. <Br>
You can set access restrictions for the configuration file and the access control file in each directory. The setting file is composed
Set by the Administrator, and the access control files under each directory are set by the owner of the Directory, so the management <br>
You can specify whether the directory owner can overwrite the system settings in the setting file. You need to use the AllowOverride parameter to set it. Generally, the value can be set to: <br>
The impact of AllowOverride settings on the role of access control files in each directory <br>
The default value of all enables the access control file to overwrite the system configuration. <br>
None server ignores Access Control File Settings <br>
Options allows you to use the options parameter in the access control file to define the DIRECTORY Options <br>
Fileinfo allows parameters such as addtype in the access control file <br>
Authconfig allows access control files to use authentication mechanisms such as authname and authtype for each user, this allows the directory owner to use passwords and user names to protect the directory limit from limiting the IP addresses and names of clients accessing the directory. <br>
Each directory has certain attributes. You can use options to control some access attribute settings in this directory. The following are common feature options: <br>
Options setting Server feature Settings <br>
All directory features are valid, which is the default status <br>
None none of the Directory features are invalid <br>
Followsymlinks allows symbolic connections, which makes it possible for the browser to access documents outside the document root directory (DocumentRoot) symlinksifownermatch only when the purpose of the symbolic connection and the symbolic connection itself are owned by the same user, access is allowed. This setting adds some security <br>
Execcgi allows you to execute the CGI program indexes in this directory. allows the browser to send a list of files in this directory when no index.html (or other index files) exists in this directory. <br>
In addition, parameters such as order, allow, and deny are used in the preceding example. This is a method used to control access based on the browser domain name and IP address in the limit statement. Here, order defines the order in which allow and deny are processed, while allow and deny set access control for the name or IP address. In the above example, allowfrom all is used to allow all clients to access this directory, without any restrictions. <Br>
Userdir public_html <br>
When running Apache on a Linux server, all users on this computer can have their own web path, like http://example.org.cn /~ User. You can map the user to the user's webpage directory by adding the user name to the Tilde symbol. The ing directory is a sub-directory in the user's home directory. Its name is defined using the usedir parameter. The default value is public_html. If you do not want to provide webpage services for official users, use disabled as the userdir parameter. <Br>
# <Br>
# AllowOverride fileinfo authconfig limit <br>
# Options Multiviews indexes symlinksifownermatch IncludesNOEXEC <br>
# <Br>
# Order allow, deny <br>
# Allow from all <br>
# <Br>
# <Br>
# Order deny, allow <br>
# Deny from all <br>
# <Br>
# <Br>
Here we can see another usage of directory, that is, you can use a simple pattern matching method to define access control permissions for subdirectories distributed in different directories. In this way, the Apache server needs to perform additional processing on each path, which reduces the server performance. Therefore, this access restriction is not enabled by default. <Br>
Here we can see another statement, limit, which is used to set access control for specific request methods, you can use get, post, and other server-supported request methods as limit parameters to set access restrictions for different request methods. Generally, you can open the get, post, and head request methods, and shield other request methods to increase security. In the limit statement, you can use the order, allow, deny, allow, and deny methods to restrict domain names and IP addresses, except that the domain names are matched forward and backward, the IP address is matched from the front to the back. <Br>
Directoryindex index.html <br>
In many cases, the document name is not specified in the URL, but a directory name is provided. The Apache server will automatically return the files defined by directoryindex in this directory. Of course, multiple file names can be specified, and the system will search in this directory in sequence. If all the files specified by directoryindex do not exist, the Apache server can generate a list of all the files in this directory based on the system settings. In this case, the indexes option (options indexes) in the access control option of the directory must be enabled so that the server can generate a directory list. Otherwise, Apache rejects access. <Br>
Accessfilename. htaccess <br>
Accessfilename defines the name of the access control file under each directory. The default value is. htaccess. You can change this file to change the access control restrictions of different directories. <Br>
Order allow, deny <br>
Deny from all <br>
In addition to directory access control, you can also set access control based on files. <br>
Is the task of the file statement. When using the file statement, no matter which directory the file is in, the corresponding access control must be accepted as long as the name matches. This statement is important to system security. For example, in the above example, all users will be blocked from accessing the. htaccess file, so that key security information in. htaccess will not be obtained by the customer. <Br>
# Cachenegotiateddocs <br>
By default, if the proxy server negotiates with the Apache server to determine whether to cache its webpage, Apache gives <br>
In a negative response, you do not want your webpage to be cached by the proxy server. However, this method cannot effectively take advantage of the proxy server. Therefore, you can set the cachenegotiatiedocs option to enable the proxy server to cache webpages. However, even if this option is not set, some proxy servers (or by adjusting the settings) can cache webpages. <Br>
UseCanonicalName on <br>
Enabling this UseCanonicalName is the standard practice of the web server, because most of the requests sent by the client are referenced by the server, so that the server can use the servername and port options to build a complete URL, and respond to the customer so that the browser can get a standard URL. If this parameter is set to off, Apache will obtain the server name and port value from the customer request (this information will be available in requests of customers that support HTTP 1.1 ), rebuild the URL. <Br>
Typesconfig/usr/local/Apache/etc/mime. types <br>
Typeconfig is used to set the file name for storing data of different MIME types. in Linux, it is set to/usr/local/Apache/etc/mime. types by default. <Br>
Defaulttype text/plain <br>
If the Web server cannot determine the default type of a document, which usually indicates that the document uses a non-standard suffix, the server uses the MIME type defined by defaulttype to send the document to the client browser. The setting here is text/plain. The problem with this setting is that if the server cannot determine the mime of the document, this document is a binary document in most cases, however, if you use the text/plain format to send it back, the browser will open it internally without prompting to save it. Therefore, we recommend that you change this setting to <br>
Application/octet-stream, so that the browser will prompt the user to save. <Br>
Mimemagicfile/usr/local/Apache/etc/magic <br>
In addition to determining the MIME type of a file based on the file suffix, Apache can further split it into <br>
Analyzes the characteristics of a file to determine the actual MIME type of the file. This function is implemented by the mod_mime_magic module. It requires a file that records various mime-type features for analysis and judgment. The above setting is a condition statement. If this module is loaded, you must specify the location of the magic mark file. <Br>
Generally, the server can only obtain the IP address of the client during connection. If you want to obtain the IP address of the client, <br>
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. <Br>
Errorlog/var/log/httpd-error.log <br>
Loglevel warn <br>
Logformat & quot; % H % L % u % T & quot; % R & quot; % & gt; S % B & quot; % {Referer} I & quot; & quot; % {User-Agent} & quot; combined <br>
Logformat & quot; % H % L % u % T & quot; % R & quot; % & gt; S % B & quot; common <br>
Logformat & quot; % {Referer} I-& gt; % u & quot; Referer <br>
Logformat & quot; % {User-Agent} I & quot; Agent <br>
# Customlog/var/log/httpd-access.log common <br>
# Customlog/var/log/httpd-referer.log Referer <br>
# Customlog/var/log/httpd-agent.log agent <br>
Customlog/var/log/httpd-access.log combined <br>
The system log format is defined here. For server error records, errorlog and loglevel define different error log files and their recorded content. <Br>
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. <Br>
Obviously, logformat is used to define different types of logs for record. Here <br>
The macro definition starting with % is used to record different contents. <Br>
If the file specified by these parameters uses a relative path, it is relative to serverroot. <br>
Path. <Br>
Serversignature on <br>
In some cases, for example, when the webpage requested by the customer does not exist, the server generates an error document. <br>
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. <br>
You can set this parameter to off or email. The last line will be replaced with the email prompt for serveradmin. <Br>
Alias/icons/& quot;/www/icons/& quot; <br>
Options indexes Multiviews <br>
AllowOverride none <br>
Order allow, deny <br>
Allow from all <br>
The alias parameter is used to directly map the URL to the real location in the Server File System. Generally, <br>
The document will be queried in DocumentRoot, but the path defined by alias will be mapped directly to the phase <br>
Instead of querying under DocumentRoot. Therefore, alias can be used to map some <br>
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 (DocumentRoot) can also be accessed by using alias ing. <Br>
After defining the ing path, you must use the directory statement to set access restrictions. <Br>
ScriptAlias/cgi-bin/& quot;/www/cgi-bin/& quot; <br>
AllowOverride none <br>
Options none <br>
Order allow, deny <br>
Allow from all <br>
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. <Br>
# Redirect old-Uri New-URL <br>
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.
More articles about Apache configuration file httpd. conf [conversion] (2)
Love J2EE follow Java Michael Jackson video station JSON online tools
Http://biancheng.dnbcw.info/php/325363.html pageno: 14