Apache性能优化
Apache版本:2.4.7
一、开启缓存:
1. 修改httpd.conf文件,取消下面的注释
LoadModule expires_module modules/mod_expires.so
2. 在httpd.conf文件末尾添加以下命令
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpeg "access plus 2 weeks"
ExpiresByType image/png "access plus 2 weeks"
ExpiresByType image/gif "access plus 2 weeks"
ExpiresByType image/x-icon "access plus 2 weeks"
ExpiresByType text/css "access plus 2 weeks"
ExpiresByType application/javascript "access plus 2 weeks"
</IfModule>
二、开启Gzip压缩:
1. 修改httpd.conf文件,取消下面的注释
LoadModule deflate_module modules/mod_deflate.so
LoadModule headers_module modules/mod_headers.so
LoadModule filter_module modules/mod_filter.so
2. 在httpd.conf文件末尾添加以下命令
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript
AddOutputFilter DEFLATE css js
</IfModule>
三、参数调优:
1. 修改$APACHE/conf/extra/httpd-mpm.conf
<IfModule mpm_prefork_module>
StartServers 5
MinSpareServers 5
MaxSpareServers 10
ServerLimit 2000
MaxRequestWorkers 2000
MaxConnectionsPerChild 500
</IfModule>
四、重写优化
1. 静态文件不进行重写
RewriteCond %{REQUEST_URI} !^.*(.css|.js|.gif|.png|.jpg|.ico)$