- 定义配置文件
vhost.conf
<directory /www>
allowoverride none
require all granted
</directory>
<virtualhost 192.168.209.136:80>
documentroot /www
servername 192.168.209.136
</virtualhost>
<virtualhost 192.168.209.138:80>
documentroot /www/138
servername 192.168.209.138
</virtualhost>
<virtualhost 192.168.209.139:80>
documentroot /www/139
servername 192.168.209.139
</virtualhost>
- 创建目录
[root@localhost conf.d]# mkdir /www/{138,139}
- 写内容
[root@localhost conf.d]# echo welcome to 138 > /www/138/index.html
[root@localhost conf.d]# echo welcome to 139 > /www/139/index.html
- 添加上述配置文件中的IP
[root@localhost conf.d]# nmcli connection modify ens160 ipv4.addresses 192.168.209.136/24
[root@localhost conf.d]# nmcli connection modify ens160 ipv4.gateway 192.168.209.2
# 将 ens160 网络连接的 IPv4 配置方法修改为手动配置。
[root@localhost conf.d]# nmcli connection modify ens160 ipv4.method manual
# 设置 ens160 网络连接在系统启动时自动连接。
[root@localhost conf.d]# nmcli connection modify ens160 connection.autoconnect yes
# 激活 ens160 网络连接。
[root@localhost conf.d]# nmcli connection up ens160
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/3)
# 添加新的IP地址
[root@localhost conf.d]# nmcli connection modify ens160 +ipv4.addresses 192.168.209.138/24
[root@localhost conf.d]# nmcli connection modify ens160 +ipv4.addresses 192.168.209.139/24
[root@localhost conf.d]# nmcli connection up ens160
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/4)
查看IP
添加成功
- 重启httpd服务
[root@localhost conf.d]# systemctl restart httpd
- 在浏览器访问
此实验是基于上一篇实验的基础上完成的