陈力:传智播客古代 珍宝币 泡泡龙游戏开发第20讲:一个IP绑定多个域名
2015-07-21 14:33
597 查看
陈力:传智播客古代 珍宝币 泡泡龙游戏开发第20讲:一个IP绑定多个域名
在网站建设实践中,对服务器进行多域名配置是最基础的技术之一。常见的有两种方法,可以通过端口来区分不同的站点,也可以通过ServerName来区分不同的域名。本文对这两种方法结合实例进行配置。
需求说明:一个apache服务器下面有多个站点,假如域名为www.by-sj.com和www.oxlw.com 分另访问到D:\wwwroot\PHP\web1和D:\wwwroot\PHP\web3。
一、通过端口来区分不同的站点
按照绑定一个站点的方式作好准备。
(1)先进行网站建设,设计好网站,D:/wwwroot/PHP/web1和D:/wwwroot/PHP/web3 这两个站点中都有一个news.html文件。
(2)配置apache目录中的httpd.conf文件,启用Virual-hosts(启动虚拟主机的配置)。去除前面的#号。
Include conf/extra/httpd-vhosts.conf
(3)配置extra/httpd-vhosts.conf文件。
<VirtualHost 127.0.0.1:80>
DocumentRoot " D:/wwwroot/PHP/web1"
#这里配置欢迎首页面
DirectoryIndex news.html index.html index.htm index.php
<Directory />
Options FollowSymLinks
#不许可别人修改我们的页面
AllowOverride None
#设置访问权限
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
(4)在hosts文件中添加IP和域名的对应关系。
Hosts文件位于 C:\windows\system32\drivers\etc\
添加:
127.0.0.1 localhost
127.0.0.1 www.by-sj.com
(5)在httpd.conf文件中注销DocumentRoot
(6)在浏览器地址栏输入www.by-sj.com 看是否能浏览页面。第一个域名配置成功。
再添加一个域名。步骤类似上面的。
(1)先进行网站建设,设计好网站,D:/wwwroot/PHP/web3 有一个news.html文件。
(2)配置extra/httpd-vhosts.conf文件。添加一个新的虚拟主机。在末尾添加代码如下:
<VirtualHost 127.0.0.1:81>
DocumentRoot "D:/wwwroot/PHP/web3"
#这里配置欢迎首页面
DirectoryIndex news.html index.html index.htm index.php
<Directory />
Options FollowSymLinks
#不许可别人修改我们的页面
AllowOverride None
#设置访问权限
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
(3)在httpd.conf文件中监听81端口。
在Listen节中添加
Listen 81
(4)在hosts文件中添加IP和域名的对应关系。再添加新的域名。
在文件末尾添加:
127.0.0.1 www.oxlw.com
(5)在浏览器地址栏输入www.oxlw.com:81 看是否能浏览页面。第二个域名配置成功。
二、通过ServerName端区分不同的域名
(1)进行贵阳网站建设,开发新的站点D:/wwwroot/PHP/web1和D:/wwwroot/PHP/web3 有一个news.html文件。
(2)在Httpd.conf文件中添加配置。和之前的不一样咯。
<VirtualHost *:80>
DocumentRoot " D:/wwwroot/PHP/web1"
#这里指定域名
ServerName www.by-sj.com
#这里配置欢迎首页面
DirectoryIndex news.html index.html index.htm index.php
<Directory />
Options FollowSymLinks
#不许可别人修改我们的页面
AllowOverride None
#设置访问权限
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot " D:/wwwroot/PHP/web3"
#这里指定域名
ServerName www.oxlw.com
#这里配置欢迎首页面
DirectoryIndex news.html index.html index.htm in
4000
dex.php
<Directory />
Options FollowSymLinks
#不许可别人修改我们的页面
AllowOverride None
#设置访问权限
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
(3)在hosts文件中添加IP和域名的对应关系。和方法一一样。
(5)在浏览器地址栏输入www.by-sj.com 和www.oxlw.com看是否能浏览页面。域名配置成功。
【推荐阅读】
陈力:传智播客古代 珍宝币 泡泡龙游戏开发第20讲:一个IP绑定多个域名
在网站建设实践中,对服务器进行多域名配置是最基础的技术之一。常见的有两种方法,可以通过端口来区分不同的站点,也可以通过ServerName来区分不同的域名。本文对这两种方法结合实例进行配置。
需求说明:一个apache服务器下面有多个站点,假如域名为www.by-sj.com和www.oxlw.com 分另访问到D:\wwwroot\PHP\web1和D:\wwwroot\PHP\web3。
一、通过端口来区分不同的站点
按照绑定一个站点的方式作好准备。
(1)先进行网站建设,设计好网站,D:/wwwroot/PHP/web1和D:/wwwroot/PHP/web3 这两个站点中都有一个news.html文件。
(2)配置apache目录中的httpd.conf文件,启用Virual-hosts(启动虚拟主机的配置)。去除前面的#号。
Include conf/extra/httpd-vhosts.conf
(3)配置extra/httpd-vhosts.conf文件。
<VirtualHost 127.0.0.1:80>
DocumentRoot " D:/wwwroot/PHP/web1"
#这里配置欢迎首页面
DirectoryIndex news.html index.html index.htm index.php
<Directory />
Options FollowSymLinks
#不许可别人修改我们的页面
AllowOverride None
#设置访问权限
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
(4)在hosts文件中添加IP和域名的对应关系。
Hosts文件位于 C:\windows\system32\drivers\etc\
添加:
127.0.0.1 localhost
127.0.0.1 www.by-sj.com
(5)在httpd.conf文件中注销DocumentRoot
(6)在浏览器地址栏输入www.by-sj.com 看是否能浏览页面。第一个域名配置成功。
再添加一个域名。步骤类似上面的。
(1)先进行网站建设,设计好网站,D:/wwwroot/PHP/web3 有一个news.html文件。
(2)配置extra/httpd-vhosts.conf文件。添加一个新的虚拟主机。在末尾添加代码如下:
<VirtualHost 127.0.0.1:81>
DocumentRoot "D:/wwwroot/PHP/web3"
#这里配置欢迎首页面
DirectoryIndex news.html index.html index.htm index.php
<Directory />
Options FollowSymLinks
#不许可别人修改我们的页面
AllowOverride None
#设置访问权限
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
(3)在httpd.conf文件中监听81端口。
在Listen节中添加
Listen 81
(4)在hosts文件中添加IP和域名的对应关系。再添加新的域名。
在文件末尾添加:
127.0.0.1 www.oxlw.com
(5)在浏览器地址栏输入www.oxlw.com:81 看是否能浏览页面。第二个域名配置成功。
二、通过ServerName端区分不同的域名
(1)进行贵阳网站建设,开发新的站点D:/wwwroot/PHP/web1和D:/wwwroot/PHP/web3 有一个news.html文件。
(2)在Httpd.conf文件中添加配置。和之前的不一样咯。
<VirtualHost *:80>
DocumentRoot " D:/wwwroot/PHP/web1"
#这里指定域名
ServerName www.by-sj.com
#这里配置欢迎首页面
DirectoryIndex news.html index.html index.htm index.php
<Directory />
Options FollowSymLinks
#不许可别人修改我们的页面
AllowOverride None
#设置访问权限
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot " D:/wwwroot/PHP/web3"
#这里指定域名
ServerName www.oxlw.com
#这里配置欢迎首页面
DirectoryIndex news.html index.html index.htm in
4000
dex.php
<Directory />
Options FollowSymLinks
#不许可别人修改我们的页面
AllowOverride None
#设置访问权限
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
(3)在hosts文件中添加IP和域名的对应关系。和方法一一样。
(5)在浏览器地址栏输入www.by-sj.com 和www.oxlw.com看是否能浏览页面。域名配置成功。
【推荐阅读】
陈力:传智播客古代 珍宝币 泡泡龙游戏开发第20讲:一个IP绑定多个域名
相关文章推荐
- 正则表达式入门浅析
- 微信公众平台开发之模板消息(Java)
- Visual C++ 在windows 7 上预编译头错误unexpected precompiled header error, simply rerunning the compiler migh
- Set Matrix Zeroes
- nslookup 通往dns的桥梁
- [错误] scp 时 ssh Connection refused
- DirectX11 常量缓存
- 包装类简介
- Android验证码倒计时的处理
- object-c 属性列表上的各个常用属性值及其含义
- android 点击listview 展开和闭合 效果
- Hibernate中 对象 的三种状态
- Java多线程--售票代码
- ios NSDateComponents 时间计算方法
- Qt QLabel::setBuddy函数
- SequoiaDB 系列之五 :源码分析之main函数
- 散列表(Hash)
- 使用xca生成SSL证书
- 【tomacat集群】Linux或 window配置多个Tomcat同时运行-完美解决-未来星开发团队-费元星
- NPOI 1.1