2014-03-22 17:50:01
来 源
itjs.cn
Linux Apache配置
本文介绍Apache服务器<directory>指令的配置说明,希望对于初学Apache服务器相关的朋友有帮助,更多Apache安装、配置、报错处理等资源请本站内搜索。
在apache的配置文件http.conf中设置如下信息,可以将该目录变成一个web可以放的目录:

Options Indexes MultiViews  FollowSymLinks

AllowOverride None

Order allow,deny

Allow from all

这里面的几个参数说明如下:

Indexes 允许目录浏览(即列出此目录下所有文件名称);MultiViews 允许内容协商的多重视图。

比如:客户端输入“http://10.0.0.1/icone/a”这将会显示此目录下所有 a.* 文件,并不是出错信息。All 包含了初MultiViews 之外的所有特性,若无Options 语句,默认为All

AllowOverride 定义对于每个目录下的 .htalless 文件中的指含类型,一般禁止使用。

设置缺省的访问权限,当前设置表示允许所有客户机都能访问。比如仅允许192.168.16.0/24 这个段能访问,除了192.168.16.5/24 之外。

使用方法:Oredr allow ,deny

Allow from 192.168.16.0/24

Deny from 192.168.16.5/24

注意: <Directory>即设置目录的访问的一些规则,常和虚拟目录连在一起使用

建立虚拟目录

1.找到"conf/httpd.conf" 文件

2.在httpd.conf里面加了如下语句

Alias /anstyla "E:/anstyla/src/web"

<Directory "E:/anstyla/src/web">

Options Indexes MultiViews

AllowOverride None

Order allow,deny

Allow from all

</Directory>

在此模块下建立虚拟目录,Alias /虚拟目录名称/ "虚拟目录路径,以[/]代替[]"

例如:Alias /admin "D:/web/admin/"

(*)/admin 为虚拟目录名称,一般不用在名称后加"/",若加入,每次都要在虚拟目录后输入"/"才能访问网站;D:/web/admin/ 为虚拟目录的物理路径.

设置默认页面

方法1 设置全局的:

<IfModule dir_module>

DirectoryIndex index.php index.php4 index.php3 index.cgi index.pl index.html index.htm index.shtml index.phtml default.php

</IfModule>

方法2 针对某一目录可以这么设置:

Alias /anstyla "E:/anstyla/src/web"

<Directory "E:/anstyla/src/web">

Options Indexes MultiViews

AllowOverride None

Order allow,deny

Allow from all

          DirectoryIndex default.php

</Directory>

声明: 此文观点不代表本站立场;转载须要保留原文链接;版权疑问请联系我们。