Apache Configuration Modifications

Source: Internet
Author: User

1. How to set the request wait time
Inside the httpd.conf set:
TimeOut N
where n is an integer and the unit is seconds.

2.
3. How to make Apache monitor on a specific port
Modify the options in httpd.conf about Listen, for example:
Listen 8000
is to enable Apache to listen on port 8000
If you want to specify both the listening port and the listening address, you can use:
Listen 192.170.2.1:80
Listen 192.170.2.5:8000
This allows Apache to simultaneously listen on port 80 of 192.170.2.1 and 192.170.2.5 8000 ports.
Of course, it can also be set in httpd.conf:
Port 80
This achieves a similar effect.
4. How to set the maximum number of idle processes in Apache
Modify the httpd.conf, set in the inside:
Maxspareservers N
where n is an integer. In this way, when the idle process exceeds n, the Apache master process will kill the spare process and keep the idle process at N, saving system resources. It is necessary to adjust this parameter in a very busy Apache site, but it is not a good idea to tune this parameter to most of them at any time.
You can also set:
Minspareservers N
To limit the minimum number of idle processes to speed up the response.
5, Apache How to set the number of child service processes at startup
Inside the httpd.conf set:
Startservers 5
After you start Apache, there are 5 idle child processes waiting to accept requests.
You can also refer to the Minspareservers and maxspareservers settings.
6. How to set the maximum number of requests per connection in Apache
Inside the httpd.conf set:
Maxkeepaliverequests 100
This ensures that in a single connection, if the number of simultaneous requests reaches 100, no longer responds to the new request of the connection, ensuring that the system resources are not heavily occupied by a connection. However, in the actual configuration, it is required to increase this value to achieve high system performance.
7. How to set the duration of the session in Apache
In the version above apache1.2, you can set it in httpd.conf:
KeepAlive on
KeepAliveTimeout 15
This allows you to limit the hold time for each session to 15 seconds. The use of the session can make a lot of requests can be sent through the same TCP connection, saving network resources and system resources.
8. How to enable Apache to verify the domain name of the client
Can be set in httpd.conf:
Hostnamelookups on|off|double
If the use on, then only one counter-check, if a double, then the reverse check after a forward parsing, only two times the results of each other, and off is not to verify the domain name.
If you want to use double for security purposes, it is recommended to use off in order to speed up access.
9, how to make Apache only listen to the specific IP
Modify httpd.conf, use bindaddress 192.168.0.1 inside
This allows Apache to listen only to HTTP requests from the outside world for 192.168.0.1. If you use:
Bindaddress *
Indicates that Apache listens for HTTP requests on all network interfaces.
Of course it can be implemented with firewalls.
1 10. How to limit the size of the message body for HTTP requests in Apache
Inside the httpd.conf set:
Limitrequestbody N
n is an integer in bytes.
CGI scripts generally submit the contents of the form to the server for processing as the body of the message, so the size of the message body is now useful when using CGI. For example, using CGI to upload files, if there are settings:
Limitrequestbody 102400
Then upload the file more than 100k will be an error.
11. How to modify the Apache document root directory
Modify the DocumentRoot option inside the httpd.conf to the specified directory, such as:
Documentroot/www/htdocs
So http://localhost/index.html is the corresponding/www/htdocs/index.html
12. How to modify the maximum number of Apache connections
Set in httpd.conf:
MaxClients N
n is an integer that represents the maximum number of connections between 1 and 256, and if you want Apache to support more connections, then you need to modify the Httpd.h file in the source code to make the defined Hard_server_limit value larger and then compile.
13, how to make each user have a separate cgi-bin directory
There are two ways to choose:
(1) in the Apache configuration file, the following properties are added to the public_html settings:
Scriptaliasmatch ^/~ ([^/]*)/cgi-bin/(. *)/home//cgi-bin/
(2) in the Apache configuration file, add the following attributes to the public_html settings: <Directory/home/*/public_html/cgi-bin>
Options execcgi
SetHandler Cgi-script
</Directory>

14, how to adjust the maximum number of Apache process
The maximum number of processes that Apache allows to open for requests is the 256,maxclients limit of 256. If you have more users, you will only see waiting for
Reply .... Then wait until the next available process appears. This maximum number is determined by the Apache program-its NT version can have 1024, but the UNIX version is only 256, you can see in the src/include/httpd.h:
#ifndef Hard_server_limit
#ifdef WIN32
#define HARD_SERVER_LIMIT 1024
#else
#define HARD_SERVER_LIMIT 256
#endif
#endif
You can set it to 1024 and then compile your system.

15. How to block users from an Internet address from accessing the Apache server
You can use Deny and allow to restrict access, such as to prevent users of 202.202.202.xx networks from accessing:
<Directory/www/htdocs>
Order Deny,allow
Deny from 202.202.202.0/24
</Directory>
16, how to record Apache browser and reference information in the log you need to compile the mod_log_config into your Apache server, and then use a configuration similar to the following:
Customlog Logs/access_log "%h%l%u%t"%r "%s%b"%i "
"%i" "
17. How to modify the head information returned by Apache
Problem Analysis: When the client connects to the Apache server, Apache will generally return the server version, non-default modules and other information, such as:
server:apache/1.3.26 (Unix) mod_perl/1.26
Solve:
You can make the following settings in the Apache configuration file to minimize the amount of information it returns about the server:
Servertokens Prod
Attention:
After this setting, Apache will also return certain server information, such as:
Server:apache
But this will not have too much impact on server security, because many scanning software is scanned in disregard of your server back to the head information. If you want to change the information returned by the server to:
Server:it is a none-apache Server
Then you will have to change the source code.

Apache Configuration Modifications

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.