Apache server configuration overview (1)

Source: Internet
Author: User
Tags types of functions
The configuration file of the Apache server is located in the usrlocalapacheconf directory. Traditionally, three configuration files httpd. conf, access. conf, and srm. conf are used to configure the behavior of the Apache server. Httpd. conf provides the most basic server configuration, which describes how the daemon httpd runs. srm. conf is a service.

The configuration file of the Apache server is located in the/usr/local/apache/conf/directory. Traditionally, three configuration files are used: httpd. conf, access. conf and srm. conf to configure the behavior of the Apache server. Httpd. conf provides the most basic server configuration, which describes how the daemon httpd runs. srm. conf is a service.

Apache ServerThe setting file is located in the/usr/local/apache/conf/directory. ConfigurationFile httpd. conf, access. conf, and srm. conf. ConfigurationApache Server.

Httpd. conf provides the most basic Server ConfigurationIs a technical description of how the daemon httpd runs. srm. conf is ServerResource ing file, tell ServerMIME types of various files, and how to support these files; access. conf is used Configuration ServerControl the access permissions of different users and computers. ConfigurationFile Control ServerFor the normal operation ServerYou need to set these three files.

In addition to these three settings files, Apache uses the mime. types file to identify different files.

For the corresponding MIME type, the magic file sets some special identifiers for different MIME types, so that Apache ServerWhen the MIME type of a file cannot be determined from the document suffix, the MIME type of the file can be determined through these special marks in the file content.

Bash-2.02 $ ls-l/usr/local/apache/conf

Total 100

-Rw-r -- 1 root wheel 348 Apr 16 16:01 access. conf

-Rw-r -- 1 root wheel 348 Feb 13 access. conf. default

-Rw-r -- 1 root wheel 30331 May 26 08:55 httpd. conf

-Rw-r -- 1 root wheel 29953 Feb 13 httpd. conf. default

-Rw-r -- 1 root wheel 12441 Apr 19 :42 magic

-Rw-r -- 1 root wheel 12441 Feb 13 magic. default

-Rw-r -- 1 root wheel 7334 Feb 13 mime. types

-Rw-r -- 1 root wheel 383 May 13 srm. conf

-Rw-r -- 1 root wheel 357 Feb 13 srm. conf. default

In fact, in the current version of Apache, all the original httpd. conf, srm. conf, and access. conf ConfigurationAll parameters are placed in one ConfigurationIn the httpd. conf file, only three configuration files are used for compatibility with previous versions (the three configuration files are used in NCSA-httpd mode ). ConfigurationFile. The access. conf and srm. conf files provided do not have specific settings.

In the new version of Apache, all the settings are placed in httpd. conf, so you only need to adjust the settings in this file. The following uses the httpd. conf provided by default as an example to explain how

Configuration options of the server. However, you don't have to worry about providing too many parameters. Basically

The parameters are clear, or you can run Apache without modifying it. Server. However, if you need to adjust the Apache service

You need to understand the meaning of the parameters.

About Apache ServerThere is a lot of controversy over the Internet. Basically, users who use Apache have almost no doubt about its excellent performance. Apache also supports many well-known high-load websites, however, in the evaluation of commercial organizations, Apache often has a low score. Many people pointed out that in these evaluations, commercial Web ServerAnd its operating systems are often adjusted by the engineers of their professional companies, while the Free operating system and Web ServerThe default value is often used. ConfigurationOr just make small changes. In addition to the performance adjustment of the operating system ServerDefault ConfigurationIt is by no means the most optimized and efficient, but to adapt to the setting of almost all types of operating systems and all types of hardware. multi-platform software cannot provide the optimal default for specific platforms and specific hardware. Configuration. Therefore, performance adjustment is essential when Apache is used.

Another fact ignored in business evaluation is that different types of functions are often compared during evaluation.

For example, the performance of Standard CGI using Apache, ISAPI, and NSAPI ServerAPI comparison, in fact, Apache ServerThe functions that can be compared with modperl, FastCGI, and PHP are similar to ASP. However, due to the open mode of Apache, these functions are developed by independent developers, implemented as an independent module. However, during the evaluation, the tester did not add a corresponding module to evaluate its performance.

Running Parameters of the HTTP daemon

Httpd. conf defines the parameters required by the httpd daemon to determine the running mode and environment.

ServerType standalone

ServerType Definition ServerThe default value is standalone and httpd.

ServerIt will be started by itself and will reside in the host to monitor connection requests. In Linux, the Web will be automatically started in the startup file/etc/rc. d/rc. local/init. d/apache. ServerThis method is recommended.

Start Apache ServerThe other method is the inet method. ServerInetd monitors connection requests and starts Server. When you need to use the inetd startup method, you need to change it to this setting and block/etc/rc. d/rc. local/init. d/apache file, and change/etc/inetd. conf and restart inetd, then Apache can start from inetd.

The difference between the two methods is that ServerManage your own startup processes.

Start immediately ServerMultiple copies, each of which reside in the memory. A connection request can be processed immediately without the need to generate a sub-process. The response to client browser requests is faster and the performance is better.

High. The inetd method starts http only after inetd discovers a connection request. ServerBecause the inetd needs to listen to too many ports, the response is slow and the efficiency is low, but the Web ServerResources used. Therefore, the inetd method is only used for access that is occasionally accessed and does not require access speed. Server. In fact, the inetd method is not suitable for http burst and multi-connection features, because a page may contain multiple images, and each image will cause a connection request, even though the number of visitors causes less teaching, however, there are many transient connection requests, which are limited by the performance of inetd and may even affect other inetd-Enabled ServerProgram.

ServerRoot "/usr/local"

ServerRoot is used to specify the running directory of the daemon httpd. After httpd is started

The current directory of the process is changed to this directory. Therefore, if the file or directory specified in the file is a relative path, the actual path is located under the path defined by ServerRoot.

Because httpd often performs concurrent file operations, it is necessary to use the locking method to ensure that file operations do not conflict. Due to the limited file lock capabilities of the NFS file system, therefore, this directory should be a local disk file system instead of an NFS file system.

# LockFile/var/run/httpd. lock

The LockFile parameter specifies the lock file of the httpd daemon. You do not need to set this parameter. ServerThe operation is automatically performed in the path under ServerRoot. However, if ServerRoot is an NFS file system, you need to use this parameter to specify the path in the local file system.

PidFile/var/run/httpd. pid

The process Number of the httpd daemon is recorded in the file specified by PidFile. Because httpd can automatically copy itself, there are multiple httpd processes in the system, but only one process is the process initially started, it is the parent process of other processes. sending signals to this process affects all httpd processes. The process Number of the httpd parent process is recorded in the file defined by PidFILE.

ScoreBoardFile/var/run/httpd. scoreboard

Httpd uses ScoreBoardFile to maintain internal data of a process. Therefore, you do not need to change this parameter unless the administrator wants to run several Apache ServerIn this case, each Apache ServerYou must set the htt pd. conf file independently and use different scoreboardfiles.

# ResourceConfig conf/srm. conf

# AccessConfig conf/access. conf

The two parameters ResourceConfig and AccessConfig are used to be compatible with the old version of Apache that uses the srm. conf and access. conf file. If there is no compatibility requirement, you can specify the corresponding setting file as/dev/null. This indicates that no other setting file exists and only httpd is used. conf file to save all the settings.

Timeout 300

Timeout defines the client program and ServerThe timeout interval of the connection. After the timeout interval (in seconds) is exceeded ServerThe connection to the client is closed.

KeepAlive On

In HTTP 1.0, only one HTTP request can be transmitted over one connection, while the KeepAlive parameter is used to support one connection and multiple transmission functions in HTTP 1.1, in this way, multiple HTTP requests can be transmitted in a connection. Although this function is only supported by newer browsers, this option is still enabled.

MaxKeepAliveRequests 100

MaxKeepAliveRequests is the maximum number of HTTP requests that a connection can perform. Set

If the value is set to 0, infinite transmission requests can be made in one connection. In fact, no client program requests too many pages in a single connection. Generally, the connection is completed if this limit is not reached.

KeepAliveTimeout 15

KeepAliveTimeout tests the time between multiple request transmissions in a connection. If Server

A request has been completed, but the next request of the customer program has not been received. The interval exceeds

After the value set for this parameter, ServerDisconnect.

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.