作者:脸皮乃身外之物 | 来源:互联网 | 2014-05-28 10:53
一、Apache配置cp/etc/httpd/conf/httpd.conf/etc/httpd/conf/httpd.confbak110820修改之前先备份原文件cp/etc/httpd/conf/httpd.confbak110820/etc/httpd/conf/httpd.conf恢复备份文件vi/etc/h
一、Apache配置
cp /etc/httpd/conf/httpd.conf
/etc/httpd/conf/httpd.confbak110820 修改之前先备份原文件
cp /etc/httpd/conf/httpd.confbak110820
/etc/httpd/conf/httpd.conf 恢复备份文件
vi /etc/httpd/conf/httpd.conf 编辑文件
============================================================================================================
ServerTokens OS ←
找到这一行,将“OS”改为“Prod”(在出现错误页的时候不显示服务器操作系统的名称)
ServerTokens ProductOnly ← 变为此状态
ServerSignature On ← 找到这一行,将“On”改为“Off”
ServerSignature Off ← 在错误页中不显示Apache的版本
Options Indexes
FollowSymLinks ←
找到这一行,删除“Indexes”,并添加“Includes”、“ExecCGI”,禁止列出目录
Options Includes ExecCGI FollowSymLinks ←
允许服务器执行CGI及SSI
AddHandler cgi-script .cgi ←
找到这一行,去掉行首的“#”,并在行尾添加“.pl”
AddHandler cgi-script .cgi .pl ←
允许扩展名为.pl的CGI脚本运行
AllowOverride None ← 找到这一行,将“None”改为“All”
AllowOverride All ← 变为此状态,允许.htaccess
LogFormat "%h %l %u %t \"%r\" %>s %b
\"%{Referer}i\" \"%{User-Agent}i\"" combined ← 找到这一行
LogFormat "%h %l %u %t \"%!414r\" %>s %b
\"%{Referer}i\" \"%{User-Agent}i\"" combined ←
改为此状态(添加“!414”到规则中,对于过长的日志不记录)
AddDefaultCharset UTF-8 ← 修改UTF-8为GB2312
AddDefaultCharset GB2312 ← (添加GB2312为默认编码)
Options Indexes MultiViews FollowSymLinks ←
找到这一行,将“Indexes”删除
Options MultiViews
FollowSymLinks ←
变为此状态(不在浏览器上显示树状目录结构)
DirectoryIndex index.html
index.html.var ← 找到这一行,修改默认首页文件
DirectoryIndex index.html index.htm Default.html
Default.htm index.php Default.php index.html.var ←
变为此状态(设置默认首页文件,增加index.php)
KeepAlive Off #修改为On 允许程序性联机
KeepAlive On
MaxKeepAliveRequests 100 #修改为1000
一次联机最大传输数量,0为不限制
MaxKeepAliveRequests 500
==================================================================
/etc/init.d/httpd restart 重启
rm -f /etc/httpd/conf.d/welcome.conf
/var/www/error/noindex.html 删除默认测试页
==================================================================