CentOS下的LAMP环境之虚拟主机

运维 系统运维
CentOS下的LAMP环境之虚拟主机:LAMP是说Linux-Apache-MySQL-PHP,LAMP网站架构是目前国际流行的Web框架。LAMP框架包括:Linux操作系统,Apache网络服务器,MySQL数据库,Perl、PHP或者Python编程语言。LAMP所有组成产品均是开源软件,是国际上成熟的架构框架。本文讲述的是CentOS下的LAMP环境之虚拟主机。

CentOS下的LAMP环境之虚拟主机(大纲

  四、配置虚拟主机及基本性能调优

  1) 配置虚拟主机:

  1.   #vi /usr/local/apache2/conf/extra/httpd-vhosts.conf  
  2.  

  代码:

  1.   NameVirtualHost *:80  
  2.  
  3.     
  4.  
  5.   ServerAdmin cnseek@gmail.com  
  6.  
  7.   DocumentRoot "/data/www/wwwroot/linuxtone.org"  
  8.  
  9.   ServerName www.linuxtone.org  
  10.  
  11.   ServerAlias bbs.linxutone.org  
  12.  
  13.   ErrorLog "logs/dummy-host.example.com-error_log"  
  14.  
  15.   CustomLog "|/usr/sbin/cronolog /data/logs/access_www.linuxtone.org.%Y%m%d"  
  16.  
  17.   combined  
  18.  

  2).基本性能调优参考

  #vi /usr/local/apache2/conf/extra/httpd-default.conf

  复制内容到剪贴板

  代码:

  1.   Timeout 15  
  2.  
  3.   KeepAlive Off  
  4.  
  5.   MaxKeepAliveRequests 50  
  6.  
  7.   KeepAliveTimeout 5  
  8.  
  9.   UseCanonicalName Off  
  10.  
  11.   AccessFileName .htaccess  
  12.  
  13.   ServerTokens Prod  
  14.  
  15.   ServerSignature Off  
  16.  
  17.   HostnameLookups Off  
  18.  
  19.   #vi /usr/local/apache2/conf/extra/httpd-mpm.conf  
  20.  

  代码:  

  1.   ServerLimit 2000  
  2.  
  3.   StartServers 10  
  4.  
  5.   MinSpareServers 10  
  6.  
  7.   MaxSpareServers 15  
  8.  
  9.   MaxClients 2000  
  10.  
  11.   MaxRequestsPerChild 10000  
  12.  

  

  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

  #下面加入如下内容:

  代码:

  1.   # filter the localhost visit  
  2.  
  3.   SetEnvIf Remote_Addr "127\.0\.0\.1" dontlog  
  4.  
  5.   # filter some special directories  
  6.  
  7.   SetEnvIf Request_URI "^ZendPlatform.*$" dontlog  
  8.  
  9.   SetEnvIf Request_URI \.healthcheck\.html$ dontlog  
  10.  
  11.   SetEnvIf Remote_Addr "::1" dontlog  
  12.  
  13.   SetEnvIf Request_URI "\.getPing.php$" dontlog  
  14.  
  15.   SetEnvIf Request_URI "^/error\.html$" dontlog  
  16.  
  17.   SetEnvIf Request_URI "\.gif$" dontlog  
  18.  
  19.   SetEnvIf Request_URI "\.jpg$" dontlog  
  20.  
  21.   SetEnvIf Request_URI "\.css$" dontlog  
  22.  

  4). Apache防盗链(Apache防盗链相关问题汇总:http://bbs.linuxtone.org/thread-101-1-1.html)

  代码:

  1.   RewriteEngine on  
  2.  
  3.   RewriteCond %{HTTP_REFERER} !^$  
  4.  
  5.   RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain.com/.*$ [NC]  
  6.  
  7.   RewriteRule \.(gif|jpg)$ http://网站域名/nolink.png [R,L]  

 

【编辑推荐】

  1. Ubuntu下LAMP的搭建
  2. Centos下搭建LAMP
  3. Linux下LAMP的安装方法
责任编辑:zhaolei 来源: javaeye
相关推荐

2011-03-23 14:38:02

LAMP架设

2011-03-09 16:16:57

CentOSLAMP

2011-03-09 16:16:56

CentOSLAMP

2011-03-09 16:16:54

CentOSLAMP

2011-03-09 16:17:20

2011-03-09 16:28:25

2011-02-25 12:29:25

Proftpd

2011-08-22 16:36:24

CentOSDirectAdmin

2017-08-15 15:24:21

2013-04-02 11:21:52

Linux操作系统虚拟主机

2011-08-16 15:16:26

UbuntuApache虚拟主机

2011-09-09 17:23:53

CentOSLAMPmysql

2010-01-11 11:19:28

Apache配置

2010-07-01 13:35:51

vsftpd

2011-06-30 17:04:05

SEO

2010-03-29 16:17:07

Nginx虚拟主机

2009-06-30 15:39:05

JSP虚拟主机

2011-03-30 15:05:41

MRTG流量图

2013-05-27 09:34:16

2011-03-10 15:44:18

CentOSLAMP安装
点赞
收藏

51CTO技术栈公众号