Linux上部署nginx实现多ip访问多网站

1,添加多个ip地址

使用nmtui命令或nmcli命令

nmtui方式:

nmcli方式:

root@localhost ip\]# nmcli conncetion ipv4.method manual ipv4.address 192.168.79.129/24 + 192.168.79.130/24 + 192.168.79.131 ipv4.gatway 192.68.79.2 ipv4.dns 114.114.114.114

激活网卡配置:

root@localhost ip\]# nmcli connection up ens160 Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/3)

查看配置是否生效:

2,在/etc/nginx/conf.d/test_ip.conf 配置文件

server{

listen 192.168.79.129:80; -----监听IP地址,端口

root /ip/129;----访问目录文件

location / { ----访问本地/目录

index index.html;----索引文件名,默认 index.html

}

}

server{

listen 192.168.79.130:80;

root /ip/130;

location / {

index index.html;

}

}

server{

listen 192.168.79.131:80;

root /ip/131;

location / {

index index.html;

}

}

3,重启nginx服务

关闭相关服务

root@localhost \~\]# systemctl stop firewalld \[root@localhost \~\]# setenforce 0

重启配置

root@localhost /\]# systemctl restart nginx

4,创建相关目录文件

root@localhost /\]# mkdir /ip/{129,130,131} -pv mkdir: created directory '/ip' mkdir: created directory '/ip/129' mkdir: created directory '/ip/130' mkdir: created directory '/ip/131' \[root@localhost /\]# echo this is 129 \> /ip/129/index.html \[root@localhost /\]# echo this is 130 \> /ip/130/index.html \[root@localhost /\]# echo this is 131 \> /ip/131/index.html

5,访问网站

相关推荐
一颗青果38 分钟前
HTTP协议详解
linux·网络·网络协议·http
Joy T3 小时前
【AI运维】02 云上基础部署:ECS、OSS 与 Nginx 的体系化理解与实践
运维·nginx
Dreamboat-L4 小时前
云服务器上部署nginx
java·服务器·nginx
广州灵眸科技有限公司4 小时前
瑞芯微(EASY EAI)RV1126B CAN使用
linux·网络·单片机·嵌入式硬件
石小千5 小时前
Nexus升级(3.63.0--3.87.1)
运维
咕噜签名-铁蛋5 小时前
AI扣子:重构人机交互的智能连接点
服务器
AI科技星6 小时前
张祥前统一场论宇宙大统一方程的求导验证
服务器·人工智能·科技·线性代数·算法·生活
魂万劫6 小时前
如何在虚拟机VM上|Linux环境内安装windows
linux·运维·服务器·windows
序属秋秋秋6 小时前
《Linux系统编程之进程控制》【进程等待】
linux·c语言·c++·进程·系统编程·进程控制·进程等待
zfj3216 小时前
top 命令中的 wa (IO wait) 指标,理论上几乎完全是由磁盘IO(包括swap)引起的,而不是网络IO
linux·网络·top·iowait