wampSever配置不同路径站点

wampserver默认的服务器站点是:\www,现对于wampserver安装地址。但有时候需要部署不同的站点到不同路径中,就需要通过wampserver进行不同路径站点配置。具体配置如下:

1.修改 httpd.conf文件,其路径:D:\software\wampserver\wamp\bin\apache\apache2.4.9\conf\ httpd.conf,找到如下语句,可直接定位513行位置。去掉Include conf/extra/httpd-vhosts.conf前的#号。

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

2.修改 httpd-vhosts.conf,添加不同路径站点配置。找到该文件。其路径:D:\software\wampserver\wamp\bin\apache\apache2.4.9\conf\extra\httpd-vhosts.conf,为其添加站点路径地址:F:/companySite,注意此处的域名是mytest(随便取的)


    DocumentRoot "F:/companySite"   #(这是你放程序的文件路径)
    ServerName mytest   #(这是自己定义的域名)
    
        Options FollowSymLinks
        AllowOverride None
        Order deny,allow
        Allow from all
        Require all granted
      

此处注意,若出现You don t have permission to access / on this server错误,查看一下上述中的这部分是否配置正确:


    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Allow from all
    Require all granted
  

3.找到httd.conf文件,其路径:D:\software\wampserver\wamp\bin\apache\apache2.4.9\conf,在65左右添加刚才配置的8085监听端口号,

Listen 0.0.0.0:8085
image.png

4.修改hosts文件,(可先拷贝一份hosts修改后直接替换),路径 C:\Windows\System32\drivers\etc\hosts
或直接通过win+r输入drivers,打开\etc\hosts文件,将刚才配置的域名添加进去。

image.png

ps: host文件是没有扩展名的系统文件,主要作用是通过定义ip地址和主机名的映射关系来加快域名解析,屏蔽网站。当用户在浏览器中输入网址是,系统会从host文件中找对应的ip地址,找到就打开网址,没找到则将网址提交DNS服务器进行ip地址的解析。

5.在F:\companySite路径下新建index.html文件:




    
    
    Document


    恭喜你了,配置成功了


6.重启wampserver后,打开浏览器输入:http://mytest就可以访问页面了

image.png

参考
https://blog.csdn.net/u014607184/article/details/81840306

wampserver一致报橙色:
https://blog.csdn.net/m0_37249791/article/details/85253041?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-4.nonecase&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-4.nonecase

你可能感兴趣的:(wampSever配置不同路径站点)