directory title
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
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
Multiple ports to access multiple websites
[root@localhost ~]# vim /etc/httpd/conf.d/vhosts.conf
Write the following code into it
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
Access multiple websites based on domain name
[root@localhost ~]# vim /etc/httpd/conf.d/vhosts.conf
Write the code below
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
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