Web服务器 多IP访问网站
操作
1.关闭防火墙
[root@localhost xzy]# systemctl stop firewalld
[root@localhost xzy]# setenforce 0
2.安装nginx(已安装)
[root@localhost xzy]# yum install nginx
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered with an entitlement server. You can use subscription-manager to register.
Last metadata expiration check: 2:36:57 ago on Sun 20 Oct 2024 02:49:14 PM CST.
Package nginx-1:1.20.1-14.el9_2.1.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!
3.使用nmuti创建IP
[root@localhost xzy]# nmcli connection up ens160
4.创建text文件并配置文件
server {
listen 192.168.194.200:80;
root /www/ip/200;
location / {
index 200.html;
}
}
server {
listen 192.168.194.250:80;
root /www/ip/250;
location / {
index 250.html;
}
}
5.创建文件并填写表示内容
[root@localhost xzy]# mkdir /www/ip/200 -pv
mkdir: created directory '/www'
mkdir: created directory '/www/ip'
mkdir: created directory '/www/ip/200'
[root@localhost xzy]# mkdir /www/ip/250 -pv
mkdir: created directory '/www/ip/250'
[root@localhost xzy]# echo xzy200 > /www/ip/200/200.html
[root@localhost xzy]# echo xzy250 > /www/ip/250/250.html
[root@localhost xzy]# systemctl restart nginx
重启nginx