安装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       #重启
相关推荐
me8322 小时前
【Java】踩坑实录:Spring Boot + Nginx 本地部署404终极排查:从80端口被占用到配置生效全流程
java·spring boot·nginx
lang201509282 小时前
Logback TCP 远程日志实战:构建高可用的集中式日志中心
网络协议·tcp/ip·logback
卤炖阑尾炎6 小时前
Web 技术基础与 Nginx 网站环境部署全解析
前端·nginx·microsoft
2401_858936886 小时前
深入浅出 TCP 通信:从基础到并发服务器实现
服务器·网络·tcp/ip
鲨辣椒100866 小时前
TCP连接有多函数接口阻塞问题???——TCP并发服务器的实现
服务器·网络协议·tcp/ip
银河麒麟操作系统6 小时前
银河麒麟桌面操作系统V10SP1(全X86/ARM架构)【进程资源限制与性能优化实践】技术文章
arm开发·性能优化·架构
永远不会出bug6 小时前
调整nginx代理 并获取到访问你网站的用户本机 IP
运维·tcp/ip·nginx
2401_858936886 小时前
深入理解 TCP 并发服务器:从 IO 模型到多路复用实现
服务器·tcp/ip·php
LCG元7 小时前
以太网通信实战:STM32F407+LAN8720A+LwIP,TCP/IP协议栈应用
stm32·嵌入式硬件·tcp/ip
BullSmall7 小时前
Nginx(反向代理、负载均衡)安全加固
nginx·安全·负载均衡