一个IP绑定多个域名(虚拟主机)设置方法


1.事先建立两个域名站点

  分别建立web1和web2站点,分别建立主页面web1.html和web2.html;

2.在httpd.conf文件中启用httpd-vhosts.conf

  去掉#,即

#Virtual hosts (虚拟主机)
Include conf/extra/httpd-vhosts.conf

3.设置http-vhosts.conf文件(路径:X:/ApacheX.X/conf/extra/http-vhosts.conf)

  添加以下内容:

#配置虚拟主机
<VirtualHost *:80> DocumentRoot "d:/web1" ServerName www.ayee1.com
    #配置欢迎首页面
    DirectoryIndex web1.html index.html index.htm index.php
    <Directory />
    Options FollowSymLinks
    #不许别人修改网站页面
    AllowOverride None
    #设置访问权限
    Order allow,deny
    Allow from all
    </Directory>
</VirtualHost>

#配置虚拟主机
<VirtualHost *:80> DocumentRoot "d:/web2" ServerName www.ayee2.com
    #配置欢迎首页面
    DirectoryIndex web2.html index.html index.htm index.php
    <Directory />
    Options FollowSymLinks
    #不许别人修改网站页面
    AllowOverride None
    #设置访问权限
    Order allow,deny
    Allow from all
    </Directory>
</VirtualHost>

4.在hosts文件中添加我们的ip和主机映射关系(路径:c:/windows/system32/drivers/etc/hosts)

  在 127.0.0.1  localhost下添加如下地址

127.0.0.1    www.ayee1.com
127.0.0.1    www.ayee2.com

配置完成。

现在就可以在同一个ip下访问两个域名(www.ayee1.com和www.ayee2.com)站点了。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM