LINUX Under Apache Server Configuration Raiders (1) httpd.conf

zhaozj2021-02-11  213

LINUX Apache Server Configuration Raiders (1)

Author: Bo OSO Oso

The setup file of the Apache server is located in the / usr / local / apache / conf / directory, traditionally uses three configuration files httpd.conf, access.conf, and srm.conf to configure the behavior of the Apache server.

Httpd.conf provides the most basic server configuration, which is a technical description of how the daemon HTTPD is running; SRM.CONF is the server's resource mapping file, telling the MIME type of the server, and how to support these files; access.conf Used to configure access to servers, control access restrictions of different users and computers; these three configuration files control all of the features of the server, so these three files need to be set to normal running the server.

In addition to these three setup files, Apache also uses mime.types files to identify different files.

Corresponding MIME types, the MAGIC file sets some special identifiers for different MIME type files, so that when the Apache server cannot determine the MIME type of the file from the document suffix, it can determine the MIME type of the document through these special tags in the file content.

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

Total 100

-rw-r - r - 1 root wheel 348 APR 16 16:01 Access.conf

-rw-r - r - 1 root wheel 348 Feb 13 13:33 Access.conf.default

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

-rw-r - r - 1 root wheel 29953 Feb 13 13:33 httpd.conf.default

-rw-r - r - 1 root wheel 12441 APR 19 15:42 MAGIC

-rw-r - r - 1 root wheel 12441 feb 13 13:33 Magic.default

-rw-r - r - 1 root wheel 7334 Feb 13 13:33 mime.types

-rw-r - r - 1 root wheel 383 May 13 17:01 Srmm.conf

-rw-r - r - 1 root wheeel 357 Feb 13 13:33 Srm.conf.default

In fact, the current version of Apache will be the original httpd.conf, all the configuration parameters in SRM.CONF and Access.conf are in a configuration file httpd.conf, just for the previous version (use these three Setting the file from NCSA-httpd to use three profiles. There is no specific settings in the access.conf and SRM.conf files.

Since all settings are placed in httpd.conf in the new version of Apache, they only need to adjust the settings in this file. The following uses the default httpd.conf as an example, explain Apache service

Each setting option for the instructor. However, it is not necessary to worry about it, it is basically these parameters.

The parameters are clear, or the Apache server can also be run without a change. But if you need to adjust the Apache service

The performance of the device, and support for some feature, you need to understand the meaning of these setting parameters.

Regarding the performance of the Apache server, there is a big controversy on the Internet. Basically, the user who uses Apache almost does not doubt its excellent performance, and Apache has also supported a lot of famous high-load websites, but in the assessment of commercial institutions. Apache tends to score. Many people pointed out that in these reviews, commercial web servers and their operating systems often perform performance adjustments by engineers from their professional companies, and free operating systems and web servers often use their default configuration or only small changes. . It should be pointed out that in addition to the performance adjustment of the operating system, the default configuration of the Apache server itself is never optimized and most efficient, but to adapt to almost all kinds of operating systems, all kinds of hardware settings, multi-platform Software is not possible to provide optimized default configurations for specific platforms and specific hardware. Therefore, performance adjustments are essential when using Apache. Another fact that is ignored in business evaluation is that different types of functions are often comparison trends.

Moreover, for example, the performance of the standard CGI using Apache compares server-side APIs such as ISAPI, NSAPI. In fact, the Apache server can compare the function of modperl, fastcgi, similar to the ASP similar to PHP, but only due to Apache Open mode, these functions are implemented by an independent development group as a stand-alone module. However, in the evaluation, the tester did not join the corresponding module to evaluate its performance.

HTTP daemon running parameters

HTTPD.conf first defines the parameters required for the HTTPD daemon runtime to determine its operating mode and running environment.

Servertype Standalone

ServerType Defines the server's startup method, default is independent mode Standalone, httpd

The server will be launched by itself and resides in the host to monitor connection requests. This way is a recommended settings in the launch file /etc/rc.d/rc.local/init.d/apache under Linux.

Another way to start the Apache server is the inet mode, using the Super Server INETD to monitor the connection request and start the server. When you need to use the inetd startup mode, you need to change to this setting, and mask the /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 ways is that the independent mode is manifested by the server itself, which is in this way.

You can immediately start multiple copies of the server. Each copy resides in memory, and a connection request does not need to generate a child process. It can be processed immediately. The request for the customer browser is faster and more performance.

high. The inetd method is to start the HTTP server after the connection request is found by inetd. Since inetd is listening to too many ports, the reaction is slower, the efficiency is low, but saves the resources that the web server occupied when there is no connection request. Therefore, inetd is only used by occasionally accessing and does not require access to a server. In fact, the inetd method is not suitable for http's burst and multi-connection characteristics, because a page may contain multiple images, while each image can cause a connection request, even though the number of visitors teach less, but instantaneous connection request Many, this is limited by inetd performance, and even other server programs started by inetd.

Serverroot "/ usr / local"

Serverroot is used to specify the run directory of the daemon httpd, and HTTPD will automatically

The current directory of the process changes to this directory, so if the file or directory specified in the setup file is relative path, the real path is located under this ServerRoot definition path. Since HTTPD often makes concurrent file operations, you need to use a locking method to ensure that the file operation does not conflict, because the NFS file system is limited in the file lock, so this directory should be a local disk file system, and should not be used NFS file system.

#LOCKFILE /VAR/Run/httpd.lock

The LockFile parameter specifies the lock file of the HTTPD daemon, and does not need to set this parameter, and the Apache server will automatically operate in the path below ServerRoot. But 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 file specified by the pidfile will record the process number of the HTTPD daemon. Since HTTPD can automatically copy itself, there are multiple httpd processes in the system, but only one process is the initial process, which is the father process of other processes, for this The process sends signal will affect all HTTPD processes. The process number of the HTTPD parent process is recorded in the file defined by the PIDFile.

ScoreboardFile /var/run/httpd.scoreboard

HTTPD uses ScoreboardFile to maintain internal data of the process, so you usually do not need to change this parameter, unless the administrator wants to run a few Apache servers on a computer, each Apache server requires a separate setup file htt pd.conf, And use different scoreboardfiles.

#ResourceConfig conf / srm.conf

#Accessconfig conf / access.conf

These two parameters ResourceConfig and AccessConfig are used to be compatible with the old version Apache that uses srm.conf and Access.conf. If there is no compatible need, you can specify the corresponding setup file as / dev / null, which will indicate that there is no other setup file, but only use httpd.conf a file to save all settings options.

TIMEOUT 300

Timeout defines a user program and a server connection for time separation, which exceeds this time interval (second), the server will disconnect the connection with the client.

Keepalive ON

In HTTP 1.0, a connection can only be transmitted once a HTTP request, while the KeepAlive parameter is used to support a connection, multiple transmission functions, which can pass multiple HTTP requests in a single connection. Although this feature is only supported by a newer browser, it is also open to use this option.

MaxkeepaliveRequests 100

MaxkeepAliveRequests is the maximum number of requests for HTTP requests for a connection. will

Its value is set to 0 will support an unlimited transmission request within a single connection. In fact, there is no customer program to request too many pages in a connection, usually do not reach this upper limit to complete the connection.

KeepaliveTimeout 15

KeepaliveTimeout tests time between multiple request transfers in a connection, if the server

A request has been completed, but it has not received the next request for the client program, and it is more than the interval.

After this parameter is set, the server is disconnected.

>> Previous article: Linux offered DHCP Raiders >> Next article: Linux Apache Server Configuration Raiders (2)

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

New Post(0)