Apache server configuration skills

Source: Internet
Author: User

1. How to set the request wait time

In httpd. conf, set timeout n to an integer in seconds. Setting this timeout applies to three situations:

2. How to receive the total time of a GET request

Time Interval Between TCP packets that receive a post and put Request Response (ACK) during TCP packet transmission

3. How to make Apache listening on a specific port

Modify httpd. the listen option in Conf. For example, listen 8000 enables Apache to listen on port 8000. To specify both the listening port and listening address, you can use listen 192.170.2.1: 80 listen 192.170.2.5: in this way, Apache listens to port 80 of port 192.170.2.1 and port 8000 of port 192.170.2.5 at the same time. Of course, you can also set port 80 in httpd. conf to achieve similar results.

4. How to set the maximum number of idle processes of Apache?

Modify httpd. conf and set: maxspareservers n, where n is an integer. In this way, when the number of idle processes exceeds N, the Apache Master process will kill redundant idle processes and keep the number of idle processes at N, saving system resources. It is necessary to adjust this parameter at a very busy Apache site, but it is not a good idea to adjust this parameter at any time. You can also set minspareservers n to limit the minimum number of idle processes to speed up the response.

5. How does Apache set the number of sub-service processes at startup?

In httpd. conf, set startservers 5. After Apache is started, five idle sub-processes are waiting to accept requests. You can also refer to minspareservers and maxspareservers settings.6. How to set the maximum number of requests for each connection in Apache?

In httpd. in the conf file, set maxkeepaliverequests 100 to ensure that the new connection request is no longer responded if the number of requests reaches 100 at the same time, this ensures that system resources are not greatly occupied by a connection. However, in actual configuration, we recommend that you increase the value as much as possible to achieve high system performance.

7. How to set the session duration in Apache

In apache1.2 or later versions, you can set keepalive on keepalivetimeout 15 in httpd. conf to limit the holding time of each session to 15 seconds. Session usage allows many requests to be sent over the same TCP connection, Saving network resources and system resources.

8. How to make Apache perform domain name verification on the client

It can be found in httpd. set in conf: hostnamelookups on | off | double if on is used, only one reverse query is performed. If double is used, a forward resolution is performed after the reverse query, only two results match each other, and off means domain name verification is not performed. Double is recommended for security purposes. to speed up access, off is recommended.

9. How to make Apache only listen to specific IP addresses?

Modify httpd. conf and use bindaddress 192.168.0.1 to enable Apache to only listen to external HTTP requests for 192.168.0.1. If bindaddress * is used, Apache listens to HTTP requests from all network interfaces. Of course, firewall can also be used.

10. How to limit the size of the message body of an HTTP request in Apache?

In httpd. conf, set limitrequestbody n to an integer in bytes. CGI scripts generally submit the content in the form as the message body to the server for processing. Therefore, the size of the message body is useful when CGI is used. For example, if you use CGI to upload a file and set it to limitrequestbody 102400, an error will be reported when the size of the uploaded file exceeds kb.11. How to modify the Apache document root directory

Modify the DocumentRoot option in httpd. conf to the specified directory. For example, http: // localhost/index.html like DocumentRoot/www/htdocs is the corresponding/www/htdocs/index.html
12. How to modify the maximum number of connections of Apache

In httpd. set in conf: the value of maxclients N is an integer, indicating the maximum number of connections. The value range is between 1 and 256. If you want Apache to support more connections, you need to modify httpd in the source code. h file, change the defined hard_server_limit value to a large value, and then compile.

13. How to make each user have an independent cgi-bin directory

There are two options: (1) Add the following attributes to the public_html settings in the Apache configuration file: scriptaliasmatch ^ /~ ([^/] *)/Cgi-bin /(. *)/home // cgi-bin/(2) Add the following attributes to the public_html settings in the Apache configuration file: <directory/home/*/public_html/cgi-bin> options execcgi sethandler CGI-script </directory>

14. how to adjust the maximum number of Apache Processes

The maximum number of processes allowed for requests in Apache is 256, and the limit of maxclients is 256. if there are more users, you can only see waiting for reply .... wait until the next available process appears. The maximum number is determined by the Apache program-its NT Version can have 1024, but the unix version only has 256, you can go to src/include/httpd. in H, we can see: # ifndef hard_server_limit # ifdef Win32 # define hard_server_limit 1024 # else # define hard_server_limit 256 # endif. You can tune it to 1024 and then compile your system.

15. How to shield users from an Internet address from accessing the Apache server

Deny and allow can be used to restrict access. For example, to prohibit access from users in the 202.202.202.xx Network: <directory/www/htdocs> order deny, allow deny from 202.202.202.0/24 </directory>

16. How to record Apache browser and reference information in logs

You need to compile mod_log_config to your Apache server, and then use the following configuration similar to the following: customlog logs/access_log "% H % L % u % t" % R "% S % B" % I "" % I ""

17. How to modify the header information returned by Apache

Problem Analysis: when the client is connected to the Apache server, Apache generally returns the server version, non-default module, and other information, such as: SERVER: Apache/1.3.26 (UNIX) mod_perl/1.26 solution: you can make the following settings in the Apache configuration file to minimize the server information it returns: ServerTokens prod Note: after this setting, Apache will return certain server information, for example: server: Apache, but this does not have too much impact on server security, because many scanning software does not check the header information returned by your server during scanning. If you want to change the information returned from the server to: SERVER: it is a none-Apache server, you have to modify the source code.

Apache server configuration skills

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.