您的位置:我是网管博客 » 特蓝克斯 -- Amanda 的生活 » 日志
win+apache下配置虚拟主机和绑定域名
上一篇 / 下一篇 2008-07-13 10:44:11 / 个人分类:apache
查看( 34 ) /
评论( 2 )
在WIN下安装APACHE配置虚拟目录和UNIN/LINUX下基本是一样的,只是目录不同罢啦,这点大家都应该很清楚了,偶就不多说了
今天上午配置了一下一个ip绑定多个域名多站点的配置,刚开始时配置属实头疼,不过大家看过下面我写的总结后,估计应该会找到一些出路,当然了,首先你要对APACHE有一定的了解,这里不多做解释。
就是修改httpd.conf
1:单个IP对应单个域名
这个很简单,其实不用做任何修改,默认域名绑定DNS后,对应的80端口的站就是,不过还是需要配置一下,希望各位熟悉一下。
例如:www.54php.com对应IP为 192.168.1.1
在httpd.conf中加入如下指令
#对应域名所指向的IP
DocumentRoot "D:/web/54php" #www.54php.com要指向的目录,注意一定要有 ""
ServerNamewww.54php.com#所要绑的域名
#对应域名所指向的IP
DocumentRoot "D:/web/walkingbar" #www.walkingbar.cn要指向的目录,注意一定要有""
ServerName www.walkingbar.cn #所要绑的域名
剩下的可以继续绑!
2:单个IP对应多个域名
这个地方可能刚接触的朋友会比较棘手,不过做过一次配置之后,就会比较轻松的上手了,下面我来介绍一下下了。
NameVirtualHost 192.168.1.1 #记得一定要有着句啊!一定要写你的公网IP,否则无效
#对应域名所指向的IP
DocumentRoot "D:/web/54php" #www.54php.com要指向的目录,注意一定要有""
ServerName www.54php.com #所要绑的域名
#对应域名所指向的IP
DocumentRoot "D:/web/walkingbar" #www.walkingbar.cn要指向的目录,注意一定要有""
ServerName www.walkingbar.cn #所要绑的域名
这样就绑上对应的目录了,如果没有NameVirtualHost 192.168.1.1 这个指令的话,所有的域名就都指到php目录了.
今天上午配置了一下一个ip绑定多个域名多站点的配置,刚开始时配置属实头疼,不过大家看过下面我写的总结后,估计应该会找到一些出路,当然了,首先你要对APACHE有一定的了解,这里不多做解释。
就是修改httpd.conf
1:单个IP对应单个域名
这个很简单,其实不用做任何修改,默认域名绑定DNS后,对应的80端口的站就是,不过还是需要配置一下,希望各位熟悉一下。
例如:www.54php.com对应IP为 192.168.1.1
在httpd.conf中加入如下指令
#对应域名所指向的IP
DocumentRoot "D:/web/54php" #www.54php.com要指向的目录,注意一定要有 ""
ServerNamewww.54php.com#所要绑的域名
<VirtualHost *:80>
ServerAdmin 54php@54php.com
DocumentRoot "D:/web/54php"
DirectoryIndex index.php index.php4 index.php3 index.cgi index.pl index.html index.htm index.shtml index.phtml
ServerName www.54php.com
<Directory "D:/web/54php">
Options Indexes FollowSymLinks
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
ServerAdmin 54php@54php.com
DocumentRoot "D:/web/54php"
DirectoryIndex index.php index.php4 index.php3 index.cgi index.pl index.html index.htm index.shtml index.phtml
ServerName www.54php.com
<Directory "D:/web/54php">
Options Indexes FollowSymLinks
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
#对应域名所指向的IP
DocumentRoot "D:/web/walkingbar" #www.walkingbar.cn要指向的目录,注意一定要有""
ServerName www.walkingbar.cn #所要绑的域名
剩下的可以继续绑!
2:单个IP对应多个域名
这个地方可能刚接触的朋友会比较棘手,不过做过一次配置之后,就会比较轻松的上手了,下面我来介绍一下下了。
NameVirtualHost 192.168.1.1 #记得一定要有着句啊!一定要写你的公网IP,否则无效
#对应域名所指向的IP
DocumentRoot "D:/web/54php" #www.54php.com要指向的目录,注意一定要有""
ServerName www.54php.com #所要绑的域名
#对应域名所指向的IP
DocumentRoot "D:/web/walkingbar" #www.walkingbar.cn要指向的目录,注意一定要有""
ServerName www.walkingbar.cn #所要绑的域名
NameVirtualHost 192.168.1.1
<VirtualHost 192.168.1.1:80>
ServerAdmin webmaster@54php.com
DocumentRoot "D:/web/54php"
DirectoryIndex index.php index.php4 index.php3 index.cgi index.pl index.html index.htm index.shtml index.phtml
ServerName www.54php.com
<Directory "D:/web/54php">
Options Indexes FollowSymLinks
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost 192.168.1.1:80>
ServerAdmin webmaster2@walkingbar.cn
DocumentRoot "D:/web/walkingbar"
DirectoryIndex index.php index.php4 index.php3 index.cgi index.pl index.html index.htm index.shtml index.phtml
ServerName www.walkingbar.cn
<Directory "D:/web/walkingbar">
Options Indexes FollowSymLinks
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost 192.168.1.1:80>
ServerAdmin webmaster@54php.com
DocumentRoot "D:/web/54php"
DirectoryIndex index.php index.php4 index.php3 index.cgi index.pl index.html index.htm index.shtml index.phtml
ServerName www.54php.com
<Directory "D:/web/54php">
Options Indexes FollowSymLinks
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost 192.168.1.1:80>
ServerAdmin webmaster2@walkingbar.cn
DocumentRoot "D:/web/walkingbar"
DirectoryIndex index.php index.php4 index.php3 index.cgi index.pl index.html index.htm index.shtml index.phtml
ServerName www.walkingbar.cn
<Directory "D:/web/walkingbar">
Options Indexes FollowSymLinks
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
这样就绑上对应的目录了,如果没有NameVirtualHost 192.168.1.1 这个指令的话,所有的域名就都指到php目录了.
-
5522117
发布于2008-07-14 10:01:18
-
支持好贴,学习学习