配置apache虚拟目录与虚拟主机

来源:互联网 发布:虚拟网络传销中的三虚 编辑:程序博客网 时间:2024/04/30 12:28

一、配置虚拟目录

配置虚拟目录主要是为了安全。找到httpd.conf文件,在<IfModule dir_module>下面加入如下配置:

<IfModule dir_module>
    #DirectoryIndex相当于是欢迎页面
DirectoryIndex index.html
#你的站点别名 随意起名字就行
Alias /ExtJS "D:/ext-3.4.0/docs"
<Directory D:/ext-3.4.0/docs>
#这是访问权限设置
Order allow,deny
Allow from all
</Directory>

</IfModule>


以后只要使用/ExtJS就能访问到d:/ext-3.4.0/docs下的文件了。


二、配置虚拟主机

如果我们想通过域名来访问而不是本地localhost来访问,可以通过配置虚拟主机来实现。

1、开启虚拟主机配置, #Include conf/extra/httpd-vhosts.conf,将#去掉;

2、添加节点

<VirtualHost  127.0.01:9080>
    DocumentRoot "D:/ext-3.4.0/docs/"

DirectoryIndex index.html

<Directory>
Options Indexes
AllowOverride none
Allow from all
    </Directory>
</VirtualHost>

3、在hosts文件中配置

127.0.0.1 web.ext.com

4、测试

0 0
原创粉丝点击