一个ip绑定多个域名

一个ip绑定一个域名

  • apache服务器文章中我有介绍apache配置网站,讲解一个ip绑定一个域名的步骤和方法。

  • 配置过程:

    • 启动httpd-vhosts.conf(在httpd.conf文件中,找到Virtual hosts虚拟主机)
      在这里插入图片描述
    • 在httpd-vhosts.conf中配置
      在这里插入图片描述
    • 修改host文件(路径+修改)
      在这里插入图片描述
      在这里插入图片描述
    • 在httpd.conf文件中加入url(url组成格式:https://www.cnblogs.com/woodyblog/p/6005414.html):
      在这里插入图片描述
    • 默认端口是80,如果之前大家没有改端口号,上面的步骤请不要改动端口号。
    • 测试
      在这里插入图片描述

一个ip绑定多个域名

  • 一个ip绑定多个域名可以采用两种方法:

    • 通过端口来区分不同的站点
    • 通过ServerName区分不同的域名

通过端口来区分不同的站点

  • 配置站点。

    • E:/apache3
  • 监听端口。
    在这里插入图片描述

  • 配置httpd.conf文件,启动httpd-vhosts.conf(假设之前已经配置过网站可忽略此步骤)。
    在这里插入图片描述

  • 配置httpd-vhosts.conf文件。

<VirtualHost 127.0.0.1:88>
    DocumentRoot "E:/apache2"
	DirectoryIndex index.html index.htm index.php
	<Directory />
	Options FollowSymLinks
	不允许其它人修改网页
	AllowOverride None
	设置访问权限
	Order allow,deny
	Allow from all
	Require all granted
	</Directory>
</VirtualHost>

<VirtualHost 127.0.0.1:89>
    DocumentRoot "E:/apache3"
	DirectoryIndex index.html index.htm index.php
	<Directory />
	Options FollowSymLinks
	不允许其它人修改网页
	AllowOverride None
	设置访问权限
	Order allow,deny
	Allow from all
	Require all granted
	</Directory>
</VirtualHost>
  • 在hosts文件中添加ip和域名的对应关系。
    在这里插入图片描述

  • 修改httpd.conf文件
    在这里插入图片描述

通过端口来区分不同的站点

  • 配置站点。

    • E:/apache3
  • 配置httpd.conf文件,启动httpd-vhosts.conf(假设之前已经配置过网站可忽略此步骤)。
    在这里插入图片描述

  • 配置httpd-vhosts.conf文件。

<VirtualHost *:88>
    DocumentRoot "E:/apache2"
	ServerName www.yueliang.com
	DirectoryIndex index.html index.htm index.php
	<Directory />
	Options FollowSymLinks
	#不允许其它人修改网页
	AllowOverride None
	#设置访问权限
	#Order allow,deny
	#Allow from all
	Require all granted
	</Directory>
</VirtualHost>

<VirtualHost *:88>
    DocumentRoot "E:/apache3"
	ServerName www.yueliang2.com
	DirectoryIndex index.html index.htm index.php
	<Directory />
	Options FollowSymLinks
	#不允许其它人修改网页
	AllowOverride None
	#设置访问权限
	#Order allow,deny
	#Allow from all
	Require all granted
	</Directory>
</VirtualHost>
  • 在hosts文件中添加ip和域名的对应关系。
    在这里插入图片描述
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值