Multiple ip, multiple ports, multiple domain names to access multiple websites

Multiple ip access multiple websites

The current host is configured with multiple 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

Peer configuration Configure multiple website sites based on multiple virtual host tags

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

insert image description here

Create corresponding resource files according to configuration

[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

insert image description here

Multiple ports to access multiple websites

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

Write the following code into it
insert image description here
insert image description here

Create corresponding resource files according to configuration

[root@localhost ~]# mkdir /openlab/9999
[root@localhost ~]# echo this is 9999 > /openlab/10000/index.html

Restart the httpd service

[root@localhost ~]# systemctl restart httpd  

insert image description here

Access multiple websites based on domain name

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

Write the code below
insert image description here

Create corresponding resource files

[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

restart service

[root@localhost ~]# systemctl restart httpd

insert image description here

Troubleshooting

Unsuccessful startup (there is a problem with the configuration file)

[root@localhost ~]#systemctl status httpd
[root@localhost ~]# journalctl -xe
[root@localhost ~]# httpd -t

Accessing content that is not what we define

Logical issues: analyze whether the host configuration tags match or conflict, whether
the resource file is created,
whether the matching corresponding file has permission, whether
the firewall and selinux are closed

Guess you like

Origin blog.csdn.net/weixin_64311421/article/details/130617935