• wamp 2.5 开放访问权限和设置虚拟域名


    开放访问权限

    D:wampinapacheapache2.4.9conf  里的 httpd.conf

    搜索www   把 Require local 改为 Require all granted

    DocumentRoot "d:/wamp/www/"

    #
    # Each directory to which Apache has access can be configured with respect
    # to which services and features are allowed and/or disabled in that
    # directory (and its subdirectories).
    #
    # First, we configure the "default" to be a very restrictive set of
    # features.
    #
    <Directory />
    AllowOverride none
    Require all denied
    </Directory>

    #
    # Note that from this point forward you must specifically allow
    # particular features to be enabled - so if something's not working as
    # you might expect, make sure that you have specifically enabled it
    # below.
    #

    <Directory "d:/wamp/www/">
    #
    # 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.4/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:
    # AllowOverride FileInfo AuthConfig Limit
    #
    AllowOverride all

    #
    # Controls who can get stuff from this server.
    #

    # onlineoffline tag - don't remove
    Require all granted
    </Directory>

    设置虚拟域名

    D:wampinapacheapache2.4.9conf  里的 httpd.conf

    搜索 vhost      把Include conf/extra/httpd-vhosts.conf 和 LoadModule vhost_alias_module modules/mod_vhost_alias.so 前的注释去掉

     【注: httpd.conf 里有时候也要打开这个模块   LoadModule rewrite_module modules/mod_rewrite.so】

    D:wampinapacheapache2.4.9confextra  里的  httpd-vhosts.conf

    去掉:

    <VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "c:/Apache24/docs/dummy-host.example.com"
    ServerName dummy-host.example.com
    ServerAlias www.dummy-host.example.com
    ErrorLog "logs/dummy-host.example.com-error.log"
    CustomLog "logs/dummy-host.example.com-access.log" common
    </VirtualHost>

    <VirtualHost *:80>
    ServerAdmin webmaster@dummy-host2.example.com
    DocumentRoot "c:/Apache24/docs/dummy-host2.example.com"
    ServerName dummy-host2.example.com
    ErrorLog "logs/dummy-host2.example.com-error.log"
    CustomLog "logs/dummy-host2.example.com-access.log" common
    </VirtualHost>

    如果只是想设置虚拟域名,没有同时开放权限就不用去掉,到如果要同时开放权限,就要去掉,不然开放不了。

    <VirtualHost *:80>
    DocumentRoot "D:/wamp/www/pros/"
    ServerName pros.com
    <Directory "D:/wamp/www/pros/">
    Options Indexes FollowSymLinks
    AllowOverride all
    Require all granted
    </Directory>
    </VirtualHost>


    <VirtualHost *:80>
    DocumentRoot "D:wampwww est"
    ServerName test.com

    ErrorLog "logs/dummy-host.localhost-error.log"
    CustomLog "logs/dummy-host.localhost-access.log" combined
    <Directory "D:wampwww est">
    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
    </Directory>
    </VirtualHost>

    这两个种方式都可以设置虚拟域名,哪个项目(域名)放前面(第一个),对外开放权限就是哪个项目。

    非第一个的就只能在内部访问时用虚拟域名访问(还有localhost不能用了,被第一个域名替换了,所以外部也只能访问第一个域名【当然你可以把第一个域名设置的地址直接为www,那就所以项目都可以访问得到了】)

    C:WindowsSystem32driversetc  里的 hosts

    修改本地访问

    # Copyright (c) 1993-2009 Microsoft Corp.
    #
    # This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
    #
    # This file contains the mappings of IP addresses to host names. Each
    # entry should be kept on an individual line. The IP address should
    # be placed in the first column followed by the corresponding host name.
    # The IP address and the host name should be separated by at least one
    # space.
    #
    # Additionally, comments (such as these) may be inserted on individual
    # lines or following the machine name denoted by a '#' symbol.
    #
    # For example:
    #
    # 102.54.94.97 rhino.acme.com # source server
    # 38.25.63.10 x.acme.com # x client host

    # localhost name resolution is handled within DNS itself.
    # 127.0.0.1 localhost
    # ::1 localhost

    127.0.0.1 localhost
    127.0.0.1 pros.com
    127.0.0.1 test.com

  • 相关阅读:
    数据库学习笔记5---MySQL字符串函数、日期时间函数
    关于hibernate的AnnotationConfiguration的问题
    浅谈Java web 中request的setAttribute()用法
    JAVA常见面试题之Forward和Redirect的区别
    JSP页面中<%!%>与<%%>与<%=%>
    Servlet的生命周期
    JavaEE学习路线图
    java web项目WEB-INF与META-INF的作用
    iOS-申请邓白氏编码的超详细流程介绍
    从高版本JDK换成低版本JDK报错
  • 原文地址:https://www.cnblogs.com/hfdp/p/5120397.html
Copyright © 2020-2023  润新知