安装nginx实现多ip访问多网站

一.首先安装nginx

c 复制代码
[root@server nginx]# systemctl stop firewalld   关防火墙
[root@server nginx]# setenforce 0    关selinux
[root@server nginx]# mount /dev/sr0 /mnt   挂载点
[root@server nginx]# dnf install nginx -y   安装nginx

二,添加地址

c 复制代码
[root@server nginx]# setenforce 0               #关闭selinux

[root@server nginx]# nmtui                    #写多IP

切换手动模式

将ip改为192.168.146.129和192.168.146.130

c 复制代码
[root@server nginx]# nmcli connection up ens160  #重启nmtui
[root@server nginx]# ip a   检验

编辑html

c 复制代码
[root@server nginx]#vim /etc/nginx/conf.d/test_ip.conf #编辑
[root@server nginx]# mkdir /test/{100,129,200} -pv #创建文件
[root@server nginx]# echo this is 130 > /test/129/index.html

[root@server nginx]# echo this is 139 > /test/100/index.html

[root@server nginx]# echo this is 140 > /test/200/index.html #根据配置在主机创建数据文件

[root@server nginx]# systemctl restart nginx       #重启
相关推荐
M78佐菲4 小时前
Linux学习笔记:TCP协议
linux·笔记·学习·tcp/ip·算法
KhalilRuan7 小时前
Unity性能优化
unity·性能优化·游戏引擎
米饭不加菜9 小时前
ESP-01S通过TCP直接与手机建立通信
网络·tcp/ip·智能手机
Huathy-雨落江南,浮生若梦9 小时前
Caddy 学习笔记 - 反向代理与 IP 封禁
笔记·学习·tcp/ip
姚不倒10 小时前
Nginx 反向代理:5 种负载均衡策略与实战
运维·nginx·负载均衡
Achieve前端实验室10 小时前
SSG 预渲染工具站 SEO 优化实践:从零收录到全面修复的 7 个问题
nginx·seo·前端工程化
XiaoLeisj10 小时前
Android Memory Profiler:堆内存指标、内存抖动与泄漏定位
android·性能优化·内存抖动·内存泄露·memory profiler
2401_8628808212 小时前
Linux应用层开发 --- UDP&TCP
linux·运维·tcp/ip·udp
姚不倒12 小时前
Nginx 虚拟主机:server_name 匹配规则与实战
运维·nginx