安装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       #重启
相关推荐
m0_5287238125 分钟前
前端如何进行性能优化
前端·性能优化
若云止水37 分钟前
Ubuntu 下 nginx-1.24.0 源码分析 - ngx_init_cycle 函数 - 详解(4)
数据库·nginx·ubuntu
Dontla1 小时前
Docker run --add-host参数解析(在容器启动时向/etc/hosts文件中添加自定义的主机名与IP映射)(适用于临时调试或测试)
tcp/ip·docker·容器
浪九天4 小时前
Nginx系列05(负载均衡、动静分离)
nginx·运维开发·持续部署
hgdlip9 小时前
如果更换ip地址会怎么样?网络ip地址怎么更换
网络·网络协议·tcp/ip
Mr_wilson_liu10 小时前
ssh被暴力访问了,怎么拦截ip
网络·tcp/ip·ssh
m0_7482365811 小时前
Nginx中$http_host、$host、$proxy_host的区别
运维·nginx·http
web1478621072313 小时前
Linux(CentOS)安装 Nginx
linux·nginx·centos
智慧源点14 小时前
服务端获取远程ip的方法
服务器·网络·tcp/ip
web1368856587116 小时前
Nginx 负载均衡详解
运维·nginx·负载均衡