Apache2 Optimization Configuration Summary

Source: Internet
Author: User
Tags domain lookup

Apache2 Optimization Configuration Summary
Run and test environments

Ubuntu Server 12.04 LTS

Configuration parameter Adjustment

The configuration file is generally under/etc/apache2/apache2.conf conf.d/secrity default.conf The configuration parameters I wrote below are present in these files

1.hostnamelookups off

Domain Lookup opening This will increase the burden on the AP, slowing down the access speed proposed to close

2. SetHandler Server-status

Close this otherwise exposed information.

3.allowoverride None

If you don't need to. htaccess do not need to rewrite what pseudo-static please set none otherwise all

4.option-indexes

This is a non-disclosure directory structure.

5.timeout 5

Recommended 5 This is the AP accepts the request or emits the corresponding time over this time to disconnect

6. KeepAlive on

This must be meant to be kept connected because after the HTTP 1.1 support long connection is turned on, reduce the AP every time the resource file is requested. New open process adds efficiency

7.maxkeepaliverequests 50

Maximum number of long connections to keep

8.KeepAliveTimeout 5

A long connection has not reacted after more than 5 seconds. This value can't be too big because you've been wasting your time. System resources

9.Servertokens

The response header contains the information that this setting servertokens Prod

Ten.serversignature off

This is the server that generated the 404 page information. If set off then only show Apache will not display version information

11.MPM

The key factor of this comparison is the main factors that affect the concurrency efficiency

General default Ubuntu after installation is Prefork mode if you want to use work mode, set the configuration file at compile time.

The following explains prefork This mode is relatively safe to start a process when you drop a request does not affect the other.

Here is my configuration

<ifmodule mpm_prefork_module>
Serverlimit 1000
Startservers 10
Minspareservers 30
Maxspareservers 45
MaxClients 1000
Maxrequestsperchild 3000
</IfModule>

The first serverlimit this is necessary .... Because the default maxclients 256 max you have to add limit to increase the maximum amount of service and remember to put it to the first

Startservers 10 Number of APS open

Minspareservers 30 Minimum Idle Process

Maxspareservers 45 Maximum Idle Process These 2 are adjusted according to the load and service volume of their servers

MaxClients 1000 Maximum service volume at the same time this is more critical ..... If the site is larger, increase this number but note that if it is too large to exceed the. Physical memory crashes

Maxrequestsperchild 3000 maximum number of child processes

The number configured above is my own personal machine optimal This write number please you have to according to their own actual situation through AB or JMeter and then through the top observation adjusted to the most suitable for their

Open deflate

Ln-s the following 3 modules to Mods-enable

mod_deflate.so  mod_expires.so mod_header.so

Then add the http.conf in the

<ifmodule Mod_deflate.c>addoutputfilterbytype deflate text/html text/plain text/css application/x-httpd-php                                            Text/javascript application/x-javascript text/cssaddoutputfilter DEFLATE js css #压缩js, css file # Don ' t compress images #对照片文件不进行压缩处理SetEnvIfNoCase Request_uri (?: gif|jpe?g|png) $ no-gzip dont-varyset Envifnocase Request_uri (?: Exe|t?gz|zip|bz2|sit|rar) $ no-gzip dont-varysetenvifnocase Request_URI. pdf$ no-gzip Dont-vary#setenvifnocase Request_uri. (CSS|JS) $ no-gzip dont-vary# Make sure proxies don ' t deliver the wrong contentheader append vary user-agent env=!dont-vary Deflatecompressionlevel 6SetOutputFilter Deflate</ifmodule><ifmodule mod_expires.c>expiresactive Onexpiresbytype text/css "now plus 1 month" Expiresbytype application/x-javascript "now plus 5 day" Expiresbytype Image/jpe G "Access plus 1 month" Expiresbytype image/gif "Access plus 1 month" Expiresbytype image/bmp "Access plus 1 month" Expiresby Type Image/x-icon"Access plus 1 month" Expiresbytype image/png "Access plus 1 month" Expiresbytype application/x-shockwave-flash "Access PLU S 1 Month "</IfModule>

The contents of the transfer are compressed after the gzip is turned on. So the speed is getting faster. Savings in bandwidth



After the above configuration. I use AB test performance improved ... Hundredfold...




Apache2 Optimization Configuration Summary

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.