关闭防火墙
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
下载nginx工具
[root@localhost ~]# yum install nginx
Updating Subscription Management repositories.
Unable to read consumer identityThis system is not registered with an entitlement server. You can use subscription-manager to register.Last metadata expiration check: 0:14:21 ago on Mon 21 Oct 2024 03:02:35 PM CST.Dependencies resolved.
================================================================================Package Arch Version Repository Size
================================================================================Installing:nginx x86_64 1:1.20.1-14.el9_2.1 AppStream 40 k
Installing dependencies:nginx-core x86_64 1:1.20.1-14.el9_2.1 AppStream 574 knginx-filesystem noarch 1:1.20.1-14.el9_2.1 AppStream 11 kredhat-logos-httpd noarch 90.4-2.el9 AppStream 18 kTransaction Summary
================================================================================Install 4 PackagesTotal size: 643 k
Installed size: 1.8 M
Is this ok [y/N]: y
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transactionPreparing : 1/1 Running scriptlet: nginx-filesystem-1:1.20.1-14.el9_2.1.noarch 1/4 Installing : nginx-filesystem-1:1.20.1-14.el9_2.1.noarch 1/4 Installing : nginx-core-1:1.20.1-14.el9_2.1.x86_64 2/4 Installing : redhat-logos-httpd-90.4-2.el9.noarch 3/4 Installing : nginx-1:1.20.1-14.el9_2.1.x86_64 4/4 Running scriptlet: nginx-1:1.20.1-14.el9_2.1.x86_64 4/4 Verifying : nginx-1:1.20.1-14.el9_2.1.x86_64 1/4 Verifying : nginx-core-1:1.20.1-14.el9_2.1.x86_64 2/4 Verifying : nginx-filesystem-1:1.20.1-14.el9_2.1.noarch 3/4 Verifying : redhat-logos-httpd-90.4-2.el9.noarch 4/4
Installed products updated.Installed:nginx-1:1.20.1-14.el9_2.1.x86_64 nginx-core-1:1.20.1-14.el9_2.1.x86_64 nginx-filesystem-1:1.20.1-14.el9_2.1.noarch redhat-logos-httpd-90.4-2.el9.noarch Complete!
配置IP
[root@localhost ~]# nmtui
启动ens160服务
[root@localhost ~]# nmcli connection up ens160
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/3)
查看配置是否成功
[root@localhost ~]# ip add
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00inet 127.0.0.1/8 scope host lovalid_lft forever preferred_lft foreverinet6 ::1/128 scope host valid_lft forever preferred_lft forever
2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000link/ether 00:0c:29:70:19:b2 brd ff:ff:ff:ff:ff:ffaltname enp3s0inet 192.168.64.131/24 brd 192.168.64.255 scope global noprefixroute ens160valid_lft forever preferred_lft foreverinet 192.168.64.100/24 brd 192.168.64.255 scope global secondary noprefixroute ens160valid_lft forever preferred_lft foreverinet6 fe80::20c:29ff:fe70:19b2/64 scope link noprefixroute valid_lft forever preferred_lft forever
配置多IP的配置文件
[root@localhost ~]# vim /etc/nginx/conf.d/text_ip.conf
创建显示内容的目录并编写
[root@localhost ~]# mkdir /test/{131,100} -pv
mkdir: created directory '/test'
mkdir: created directory '/test/131'
mkdir: created directory '/test/100'
[root@localhost ~]# echo 131 > /test/100/index.html
[root@localhost ~]# echo 100 > /test/100/index.html
[root@localhost ~]# echo 131 > /test/131/index.html
重启nginx服务
[root@localhost ~]# systemctl restart nginx
查看配置是否成功
[root@localhost zzy]# curl 192.168.64.131
131
[root@localhost zzy]# curl 192.168.64.100
100