CentOS下的LAMP環(huán)境之虛擬主機
CentOS下的LAMP環(huán)境之虛擬主機(大綱)
四、配置虛擬主機及基本性能調優(yōu)
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).基本性能調優(yōu)參考
#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]
【編輯推薦】