CentOS下的LAMP环境之虚拟主机(大纲)
四、配置虚拟主机及基本性能调优
1) 配置虚拟主机:
- #vi /usr/local/apache2/conf/extra/httpd-vhosts.conf
代码:
- NameVirtualHost *:80
- ServerAdmin cnseek@gmail.com
- DocumentRoot "/data/www/wwwroot/linuxtone.org"
- ServerName www.linuxtone.org
- ServerAlias bbs.linxutone.org
- ErrorLog "logs/dummy-host.example.com-error_log"
- CustomLog "|/usr/sbin/cronolog /data/logs/access_www.linuxtone.org.%Y%m%d"
- combined
2).基本性能调优参考
#vi /usr/local/apache2/conf/extra/httpd-default.conf
复制内容到剪贴板
代码:
- Timeout 15
- KeepAlive Off
- MaxKeepAliveRequests 50
- KeepAliveTimeout 5
- UseCanonicalName Off
- AccessFileName .htaccess
- ServerTokens Prod
- ServerSignature Off
- HostnameLookups Off
- #vi /usr/local/apache2/conf/extra/httpd-mpm.conf
代码:
- ServerLimit 2000
- StartServers 10
- MinSpareServers 10
- MaxSpareServers 15
- MaxClients 2000
- MaxRequestsPerChild 10000
3).Apache日志处理相关问题汇总贴
利用awstats分析网站日志:http://bbs.linuxtone.org/thread-56-1-1.html
忽略不需要的日志配置参考具体请据据具体问题分析:
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\"
\"%{User-Agent}i\"" combined
#下面加入如下内容:
代码:
- # filter the localhost visit
- SetEnvIf Remote_Addr "127\.0\.0\.1" dontlog
- # filter some special directories
- SetEnvIf Request_URI "^ZendPlatform.*$" dontlog
- SetEnvIf Request_URI \.healthcheck\.html$ dontlog
- SetEnvIf Remote_Addr "::1" dontlog
- SetEnvIf Request_URI "\.getPing.php$" dontlog
- SetEnvIf Request_URI "^/error\.html$" dontlog
- SetEnvIf Request_URI "\.gif$" dontlog
- SetEnvIf Request_URI "\.jpg$" dontlog
- SetEnvIf Request_URI "\.css$" dontlog
4). Apache防盗链(Apache防盗链相关问题汇总:http://bbs.linuxtone.org/thread-101-1-1.html)
代码:
- RewriteEngine on
- RewriteCond %{HTTP_REFERER} !^$
- RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain.com/.*$ [NC]
- RewriteRule \.(gif|jpg)$ http://网站域名/nolink.png [R,L]
【编辑推荐】