在阿帕奇上配置虚拟主机

Apache配置须知:

         Listen 80:端口监听,这个地方可以设置监听多个端口,设置方式

                   Listen 80

                   Listen 8080

         DocumentRoot ‘路径’:网站根目录

         ServerName ‘域名:80’:域名

         <Directory ‘路径’>

                   DirectoryIndex index.html index.php

                   Options Indexes

                   Order Deny,Allow

                   Allow from all

         </Directory>

 

在"httpd.conf"文件的最下端添加一下代码:

############################################
#这里以下是我们的虚拟主机(多域名)配置
############################################

#配置虚拟主机必须使用NameVirtualHost属性,意思表示所有通过80端口的请求,都会先从虚拟主机进行解析
NameVirtualHost *:80

#VirtualHost可以理解为就是一个虚拟主机
<VirtualHost *:80>

    #域名,每个虚拟主机都有一个域名对应,域名随便取
    ServerName www.php.com

    #指定网站的根目录
    DocumentRoot "F:/homework"

    #给根目录指定用户访问的权限
    <Directory "F:/homework">

    #如果没有首页的情况下,显示文件列表
        Options Indexes
        #DirectoryIndex index11.php che.html
    #权限
    Order Deny,Allow
    Allow from all
    </Directory>

    #增加一个虚拟目录
    alias /project "F:/homework/20140320"
    
    #为虚拟目录所对应的实际目录分配访问权限
    <Directory "F:/homework/20140320">
    #Options Indexes
    Order Deny,Allow
    Allow from all
    </Directory>
</VirtualHost>

#<VirtualHost *:80>
#    ServerName localhost
#    DocumentRoot "E:/Program Files/wamp/www/"
#    <Directory "E:/Program Files/wamp/www/">
#        Options Indexes
#    DirectoryIndex index.php index.html index.php3 index.htm
#    Order Deny,Allow
#    Allow from all
#    </Directory>
#</VirtualHost>

 

posted @ 2016-02-02 00:27  .追风逐月  阅读(403)  评论(0编辑  收藏  举报