黑客防线网安之Apache主站点配置实用教程_WIN2003服务器维护_黑客防线网安服务器维护基地--Powered by WWW.RONGSEN.COM.CN

黑客防线网安之Apache主站点配置实用教程

作者:黑客防线网安Apache教程网 来源:黑客防线网安Apache教程网 浏览次数:0

本篇关键词:Apache
黑客防线网安网讯:Apache的配置由httpd.conf文件配置,因此下面的配置指令都是在httpd.conf文件中修改。
Apache的配置由httpd.conf文件配置因此下面的配置指令都是在httpd.conf文件中修改

Apache主站点基本配置:
ServerRoot “/mnt/software/apache2″ #你的apache软件安装的位置其它指定的目录如果没有指定绝对路径则目录是相对于该目录。
PidFile logs/httpd.pid #第一个httpd进程(所有其他进程的父进程)的进程号文件位置。
Listen 80 #服务器监听的端口号。
ServerName www.clusting.com:80 #主站点名称(网站的主机名)。
ServerAdmin admin@clusting.com #管理员的邮件地址。
DocumentRoot “/mnt/web/clusting” #主站点的网页存储位置。

以下是对主站点的目录进行访问控制:
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all


在上面这段目录属性配置中,主要有下面的选项:
Options:配置在特定目录使用哪些特性,常用的值和基本含义如下:
ExecCGI: 在该目录下允许执行CGI脚本。
FollowSymLinks: 在该目录下允许文件系统使用符号连接。
Indexes: 当用户访问该目录时,如果用户找不到DirectoryIndex指定的主页文件(例如index.html),则返回该目录下的文件列表给用户。
SymLinksIfOwnerMatch: 当使用符号连接时,只有当符号连接的文件拥有者与实际文件的拥有者相同时才可以访问。

AllowOverride:允许存在于.htaccess文件中的指令类型(.htaccess文件名是可以改变的,其文件名由AccessFileName指令决定):
None: 当AllowOverride被设置为None时。不搜索该目录下的.htaccess文件(可以减小服务器开销)。
All: 在.htaccess文件中可以使用所有的指令。

Order:控制在访问时Allow和Deny两个访问规则哪个优先:
Allow:允许访问的主机列表(可用域名或子网,例如:Allow from 192.168.0.0/16)。
Deny:拒绝访问的主机列表。

主页文件的设置
DirectoryIndex index.html index.htm index.php #(本例将主页文件设置为:index.html,index.htm和index.php)

HTTP返头回信息配置:
ServerTokens Prod #该参数设置http头部返回的apache版本信息,可用的值和含义如下:
Prod:仅软件名称,例如:apache
Major:包括主版本号,例如:apache/2
Minor:包括次版本号,例如:apache/2.0
Min:仅apache的完整版本号,例如:apache/2.0.54
OS:包括操作系统类型,例如:apache/2.0.54(Unix)
Full:包括apache支持的模块及模块版本号,例如:Apache/2.0.54 (Unix) mod_ssl/2.0.54 OpenSSL/0.9.7g
ServerSignature Off #在页面产生错误时是否出现服务器版本信息。推荐设置为Off

持久性连接设置
KeepAlive On #开启持久性连接功能。即当客户端连接到服务器,下载完数据后仍然保持连接状态。
MaxKeepAliveRequests 100 #一个连接服务的最多请求次数。
KeepAliveTimeout 30 #持续连接多长时间,该连接没有再请求数据,则断开该连接。缺省为15秒。

别名设置
对于不在DocumentRoot指定的目录内的页面,既可以使用符号连接,也可以使用别名。别名的设置如下:
Alias /download/ “/var/www/download/” #访问时可以输入:http://www.custing.com/download/

#对该目录进行访问控制设置
Options Indexes MultiViews
AllowOverride AuthConfig
Order allow,deny
Allow from all

CGI设置
ScriptAlias /cgi-bin/ “/mnt/software/apache2/cgi-bin/” # 访问时可以:http://www.clusting.com/cgi-bin/ 。但是该目录下的CGI脚本文件要加可执行权限!

#设置目录属性
AllowOverride None
Options None
Order allow,deny
Allow from all

个人主页的设置
public_html
UserDir public_html (间用户的主页存储在用户主目录下的public_html目录下 URL http://www.clusting.com/~bearzhang/file.html 将读取 /home/bearzhang/public_html/file.html 文件)
chmod 755 /home/bearzhang #使其它用户能够读取该文件。
UserDir /var/html (the URL http://www.clusting.com/~bearzhang/file.html 将读取 /var/html/bearzhang/file.html)
UserDir /var/www/*/docs (the URL http://www.clusting.com/~bearzhang/file.html 将读取 /var/www/bearzhang/docs/file.html)

用户认证的配置
1.in the httpd.conf:

AccessFileName .htaccess
………
Alias /download/ “/var/www/download/”
Options Indexes
AllowOverride AuthConfig

2.create a password file:
/usr/local/apache2/bin/htpasswd -c /var/httpuser/passwords bearzhang

3.Configure the server to request a password and tell the server which users are allowed access.
vi /var/www/download/.htaccess:
AuthType Basic
AuthName “Restricted Files”
AuthUserFile /var/httpuser/passwords
Require user bearzhang
#Require valid-user #all valid user
    黑客防线网安服务器维护方案本篇连接:http://www.rongsen.com.cn/show-17269-1.html
网站维护教程更新时间:2012-09-12 00:39:22  【打印此页】  【关闭
我要申请本站N点 | 黑客防线官网 |  
专业服务器维护及网站维护手工安全搭建环境,网站安全加固服务。黑客防线网安服务器维护基地招商进行中!QQ:29769479

footer  footer  footer  footer