多ip,多端口、多域名访问多网站

多ip访问多网站

当前主机配置多个ip
[root@localhost ~]# nmcli connection modify ens160 ipv4.method manual ipv4.addresses  192.168.153.128/24 ipv4.gateway 192.168.153.2 ipv4.dns 114.114.114.114 +ipv4.addresses 192.168.153.128 +ipv4.addresses  192.168.153.129
[root@localhost ~]# nmcli connection up ens160
启用刚添加的ip
同行配置基于多个虚拟主机标签配置多个网站站点
[root@localhost ~]# vim /etc/httpd/conf.d/vhosts.conf

在这里插入图片描述

根据配置创建对应资源文件
[root@localhost ~]# mkdir /openlab/{128,129,138} -pv
[root@localhost ~]# echo this is 128 > /openlab/128/index.html
[root@localhost ~]# echo this is 129 > /openlab/129/index.html
[root@localhost ~]# echo this is 138 > /openlab/138/index.html

在这里插入图片描述

多端口访问多网站

[root@localhost ~]# vim /etc/httpd/conf.d/vhosts.conf

将下图代码写进去
在这里插入图片描述
在这里插入图片描述

根据配置创建对应资源文件
[root@localhost ~]# mkdir /openlab/9999
[root@localhost ~]# echo this is 9999 > /openlab/10000/index.html
重启httpd服务
[root@localhost ~]# systemctl restart httpd  

在这里插入图片描述

基于域名访问多网站

[root@localhost ~]# vim /etc/httpd/conf.d/vhosts.conf

将下图的代码写进去
在这里插入图片描述

创建对应资源文件
[root@localhost ~]# mkdir /openlab/{haha,xixi}
[root@localhost ~]# echo this is xixi > /openlab/xixi/index.html
[root@localhost ~]# echo this is haha > /openlab/haha/index.html
重启服务
[root@localhost ~]# systemctl restart httpd

在这里插入图片描述

排错方式

启动不成功(配置文件有问题)
[root@localhost ~]#systemctl status httpd
[root@localhost ~]# journalctl -xe
[root@localhost ~]# httpd -t
访问内容不是我们定义的内容

逻辑问题:分析主机 配置标签是否能匹配或是否冲突
资源文件是否创建
匹配对应文件是否有权限
防火墙,selinux是否关闭

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

流年ꦿ

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值