zoukankan      html  css  js  c++  java
  • 在apache2.2下增加新的虚拟主机

    在实际的开发测试中,有时候我们需要在本地配置很多个站点,比如:8080端口指向项目1,8081端口指向项目2。这时候我们可以通过使用以下方式来配置apache的httpd.conf文件。

    情况一:需要添加的虚拟主机是配置文件中Directory中指定目录的子目录时。

    <Directory "L:\Projects">
        #
        # Possible values for the Options directive are "None", "All",
        # or any combination of:
        #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
        #
        # Note that "MultiViews" must be named *explicitly* --- "Options All"
        # doesn't give it to you.
        #
        # The Options directive is both complicated and important.  Please see
        # http://httpd.apache.org/docs/2.2/mod/core.html#options
        # for more information.
        #
        Options Indexes FollowSymLinks
    
        #
        # AllowOverride controls what directives may be placed in .htaccess files.
        # It can be "All", "None", or any combination of the keywords:
        #   Options FileInfo AuthConfig Limit
        #
        AllowOverride None
    
        #
        # Controls who can get stuff from this server.
        #
        Order allow,deny
        Allow from all
    
    </Directory>
    Listen 8081
    <VirtualHost *:8081>
        DocumentRoot L:\Projects\web1
    </VirtualHost>

    情况二:新添加的虚拟主机与默认的Directory中的目录不同时,我们需要先添加一个新的Directory,然后再增加VirtaulHost。

    <Directory "D:/Codes">
        Options Indexes FollowSymLinks
        AllowOverride None
        Order deny,allow
        Allow from all
    </Directory>
    
    Listen 8080
    <VirtualHost *:8080>
        DocumentRoot D:\Codes
    </VirtualHost>

    如果不在这里指定新的Directory,会提示无权限访问。

  • 相关阅读:
    解决打开GitHub慢的问题
    RestFramework规范简介
    在Linux中持久化运行项目
    Linux安装Mysql
    Java基础内容汇总[持续更新]
    Elasticsearch内容汇总[持续更新]
    深入源码理解SpringBean生命周期
    利用JVM钩子函数优雅关闭线程池
    聊聊消息队列高性能的秘密——零拷贝技术
    Elasticsearch性能优化汇总——写入&搜索
  • 原文地址:https://www.cnblogs.com/AUOONG/p/2577907.html
Copyright © 2011-2022 走看看