当前位置 主页 > 服务器问题 > Linux/apache问题 >

    windows2003下apache配置虚拟主机和绑定域名服务

    栏目:Linux/apache问题 时间:2019-10-19 18:37

    本篇文章的方法大概在网上都可以找到解决方法,只是不是很明确,在这为了减少网友像我这么粗心的少走些弯路,我自己写了下一个简单明了的设置过程。
    先说下我的服务器的环境:
    windows 2003 服务器
    apache_2.0.48
    php4.2
    (我们服务器是独立IP,服务器上也没有装IIS,也没有装DNS服务器之类的,所以只能用Apache虚拟主机了)
    下面开始说设置步骤:(我这只说基于主机名的虚拟主机一个IP地址,多个网站 的配置过程,如需了解更多,请参考Apache虚拟主机文档)
    1.在windows2003下安装APACHE配置虚拟目录和UNIN下基本是一样的,就是修改httpd.conf文件(Apache2\conf\httpd.conf).
    2.打开http.conf文件,在其最下发输入
    NameVirtualHost 218.17.19.19 #记得一定要有这个啊!,这个是服务器IP地址
    <VirtualHost 218.17.19.19> #第一个域名所指向的IP
    DocumentRoot "E:/webroot/myenjoylife" #www.myenjoylife.cn要指向的目录,注意一定要有""
    ServerName www.myenjoylife.cn #第一个网站域名
    DirectoryIndex index.php index.html default.php index.html.var
    </VirtualHost>
    <VirtualHost 218.17.19.19> #第二个网站域名所指向的IP
    DocumentRoot "E:/webroot/51duanxin" #www.51duanxin.net要指向的目录,注意一定要有""
    ServerName www.51duanxin.net #所要绑的玉米
    DirectoryIndex index.php index.htm index.html default.php index.html.var
    </VirtualHost>
    NameVirtualHost 218.17.19.19 #记得一定要有这个啊!,这个是服务器IP地址
    <VirtualHost 218.17.19.19> #第一个域名所指向的IP
    DocumentRoot "E:/webroot/myenjoylife" #www.myenjoylife.cn要指向的目录,注意一定要有""
    ServerName www.myenjoylife.cn #第一个网站域名
    DirectoryIndex index.php index.html default.php index.html.var
    </VirtualHost>
    <VirtualHost 218.17.19.19> #第二个网站域名所指向的IP
    DocumentRoot "E:/webroot/51duanxin" #www.51duanxin.net要指向的目录,注意一定要有""
    ServerName www.51duanxin.net #所要绑的玉米
    DirectoryIndex index.php index.htm index.html default.php index.html.var
    </VirtualHost>
      这样就绑上对应的目录了,如果没有NameVirtualHost 218.57.19.19这个指令的话,所有的域名就都指到myenjoylife目录了.(俺就是因为这个的原因才数次没设置好,唉!)
      然后重新启动apache,就可以看到所指的域名对应相应的虚拟目录了!我这测试是没有问题的,祝大家也能够顺利解决这个小问题昂!