---
title: "Apache"
author: "johnnyhg"
date: "2008-10-17T19:05:37Z"
tags: ["Apache", "CSS", "HTML", "PHP", "SSH"]
slug: "apache"
draft: false
lastmod: "2008-10-17T19:05:37Z"
id: 254459
url: "https://johnnyhg.iteye.com/blog/254459"
---

SOS，spark！xxx网站打开奇慢，快点给看看，赶紧帮个忙解决。

于是代班超人紧急出动，SSH登录后台，按照俺一贯的二把刀操作手法：

1、检查内存使用情况  
free -m

2、查看当前进程情况  
top

以上两步未看出啥异常，那就看看apache进程吧  
ps -aux|grep apache

好象进程数是多了点，但也不离谱呀，懒得深究，重启下apache得了！（自已鄙视自己一下）

无果，还是慢，而且是一启动就很慢，这就不对劲了！而且很奇怪，一启动apache的进程数就达到httpd.conf中设置的上限了！

以我多年的经验，嘿... 被人盗链了！找出病因，下药就很简单了！

编辑httpd.conf中加入防盗链设置：

Xml代码 [![复制代码](http://gzspark.iteye.com/images/icon_copy.gif)](http://gzspark.iteye.com/blog/254390 "复制代码")

01. &lt; VirtualHost  \*:80 &gt;
02. DirectoryIndex index.htm index.html index.php
03. LogLevel debug
04. HostNameLookups off
05. ServerName www.xxxxx.com
06. ServerAlias xxxxx.com
07. DocumentRoot /var/www/html
08. SetEnvIfNoCase Referer "^http://www.xxxxx.com" local\_ref = 1
09. SetEnvIfNoCase Referer "^http://sign51.cn" local\_ref = 1
10. SetEnvIfNoCase Referer ".\*\\.xxxxx\\.com" local\_ref = 1
11. &lt; FilesMatch  "\\.(gif|jpg|png|css|swf)" &gt;
12. Order Allow,Deny
13. Allow from env = local\_ref
14. &lt;/ FilesMatch &gt;
15. &lt;/ VirtualHost &gt;

```
<VirtualHost *:80>
        DirectoryIndex index.htm index.html index.php
        LogLevel debug
        HostNameLookups off
        ServerName www.xxxxx.com
        ServerAlias xxxxx.com
        DocumentRoot /var/www/html
        SetEnvIfNoCase Referer "^http://www.xxxxx.com" local_ref=1
        SetEnvIfNoCase Referer "^http://sign51.cn" local_ref=1
        SetEnvIfNoCase Referer ".*\.xxxxx\.com" local_ref=1
        <FilesMatch "\.(gif|jpg|png|css|swf)">
                Order Allow,Deny
                Allow from env=local_ref
        </FilesMatch>
</VirtualHost>
```

其中xxxxx.com改成你自己的域名（喂，你当观众是猪呀？没力法，真的有时候就有是猪呢！）

保存后，service httpd restart搞掂收工！

本人原创文章，欢迎转载，转载请注明出处！