一个ip绑定多个域名

版权声明:版权归作者所有,转发请标明 https://blog.csdn.net/weixin_40087851/article/details/83987518

一个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和域名的对应关系。
    在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_40087851/article/details/83987518