在阿帕奇上配置虚拟主机

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>

 

转载于:https://www.cnblogs.com/xbblogs/p/5176619.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值