Apache配置多域名多目录访问

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/cjqh_hao/article/details/82793353

虚拟主机配置,分为域名和ip两种,本文只介绍前者的配置方法。

一、在httpd.conf中增加监听端口

目录 apache/conf/httpd.conf
# apache监听端口
#Listen 12.34.56.78:80
Listen 80
Listen 8080

二、增加vhost配置

目录 apache/conf/extra/httpd-vhosts.conf
增加配置项
<VirtualHost *:80>
    DocumentRoot "C:/www/test"
    ServerName larago.cn
</VirtualHost>

<VirtualHost *:8080>
    DocumentRoot "C:/www/test1"
    ServerName localhost:8080
</VirtualHost>

VirtualHost 除了上面的配置外,还可以配置目录访问权限等

三、hosts文件增加配置

目录 C:\Windows\System32\drivers\etc\hosts
增加配置项
127.0.0.1 larago.cn

重启apache服务,浏览器访问即可。
larago.cn
localhost:8080

猜你喜欢

转载自blog.csdn.net/cjqh_hao/article/details/82793353
今日推荐