服务器技术

 首页 > 服务器技术 > apache > Apache常见配置精解|root@server3-Apache教程

Apache常见配置精解|root@server3-Apache教程

分享到:
【字体:
导读:
          ...

1:让apache的索引显示支持中文文件和目录
[root@server3 ~]# tail /usr/local/apache2/conf/extra/httpd-vhosts.conf

DocumentRoot "/home/share"

Options indexes followsymlinks
order deny,allow
allow from all

ServerName   192.168.122.30


[root@server3 ~]# ls /home/share/
10网段改造问题.txt docs.zip   IPVS.doc   中文目录
boot.tgz            exam2.JPG putty.exe 数据库




[root@server3 ~]# grep -i 'utf-8' /usr/local/apache2/conf/httpd.conf
AddDefaultCharSet UTF-8
IndexOptions Charset=UTF-8



2:过滤Apache可读取的文件类型,让特定类型的文件不能被访问
root@server3 ~]# grep -A 3 -E '(exe|zip)' /usr/local/apache2/conf/httpd.conf |grep -v '#'


Order allow,deny
Deny from all



[root@server3 ~]# tail -f /usr/local/apache2/logs/error_log
[Thu May 20 14:44:25 2010] [error] [client 192.168.122.1] client denied by server configuration: /home/share/docs.zip
[Thu May 20 14:44:25 2010] [error] [client 192.168.122.1] client denied by server configuration: /home/share/putty.exe

3:重定向,重定向主要有temp,permanent,gone,seeother四种;
temp:临时重定向,用于文件当前不存在所请求的位置,将来预期会出现在该位置上时的临时重定向
permanent:永久重定向,同temp的情况相反
gone:表示文件不在此位置,以后也不应该再询问了,但gone承认文件曾经存在过,同404错误情况不同,这不会被认为是错误
seeother:告知客户端原始文件已经不存在,并且被不同位置的其他文件所替代

默认情况下,如果没有设定关键字,会使用临时重定向

DocumentRoot "/home/share"
ServerName   192.168.122.30
Redirect Permanent / http://hi.baidu.com/naruto6006




[root@server3 ~]# tail -f /usr/local/apache2/logs/access_log
192.168.122.1 - - [20/May/2010:15:03:29 +0800] "GET / HTTP/1.1" 301 238


4:apache 查看status和info信息
[root@server3 ~]# grep 'info' /usr/local/apache2/conf/httpd.conf |grep -v '#'
Include conf/extra/httpd-info.conf

[root@server3 ~]# grep -A 5 -E '(status|info)' /usr/local/apache2/conf/extra/httpd-info.conf |grep -v '#' |uniq


SetHandler server-status
Order deny,allow
Deny from all
Allow from 192.168.122.60



SetHandler server-info
Order deny,allow
Deny from all
Allow from 192.168.122.60






5:配置防盗链
第一种方法,使用SetEnvIfNoCase实现


SetEnvIfNoCase Referer "^http://([^/]*.)?yang.com" local_referrer=1
Order Allow,Deny
Allow from env=local_referrer


第二种方法,使用rewrite规则实现
[root@server3 ~]# /usr/local/apache2/bin/apachectl -l |grep rewrite
mod_rewrite.c

《Apache常见配置精解》由第二电脑网原创提供,转载请注明:http://www.002pc.com/master/College/Server/Apache/17854.html

分享到:
隐藏Apache的版本号及其它敏感信息|//-Ap...
[root@FTP-221 conf]# vi /usr/local/apache2/conf/httpd.Conf //找到httpd-default.conf,删除includes前面的“#”,改成如下 # Various default settings Include conf/extra/httpd-default.conf [root@FTP-221 conf]# vi /usr/local/apache2/conf/extra/httpd-default.conf //找到 ServerTokens Full ServerSignature On...
squid的一些技巧|acl-Apache教程
1、SQUID怎么设置某ip不能访问某网站    SQUID: acl DenyUser src 10.3.73.228/32 acl denysite dstdomain .sina.com.cn http_access deny DenyUser denysite   IPTABLES:    IPTABLES -A FORWARD    -s 10.3.73.228 -d *.*.*.* -j REJECT   --reject-with icmp-host-unreachable   2、如何禁止特定文件如...
  •         php迷,一个php技术的分享社区,专属您自己的技术摘抄本、收藏夹。
  • 在这里……