神剑山庄资源网 Design By www.hcban.com
nginx支持的虚拟主机有三种
1、基于域名的虚拟主机
2、基于IP的虚拟主机
3、基于端口的虚拟主机
一、基于域名构建
1、编译安装nginx服务
2、配置DNS域名解析服务
3、配置虚拟主机
a、创建自测网页
[root@localhost named]# cd [root@localhost ~]# mkdir -p /var/www/html/kgc [root@localhost ~]# mkdir -p /var/www/html/accp [root@localhost ~]# ls /var/www/html/accp kgc [root@localhost ~]# cd /var/www/html/ [root@localhost html]# echo "this kgc web" > kgc/index.html [root@localhost html]# echo "this accp web" > accp/index.html
b、编辑nginx.conf配置文件
vim /usr/local/nginx/conf/nginx.conf include conf.d/*.conf; server { listen 80; server_name www.kgc.com; charset utf-8; access_log logs/www.kgc.com.access.log ; location / { root /var/www/html/kgc; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } server { listen 80; server_name www.accp.com; charset utf-8; access_log logs/www.accp.com.access.log ; location / { root /var/www/html/accp; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } }
c、重载服务
systemctl restart nginx netstat -ntap | grep 80
d、访问测试
www.kgc.com
www.accp.com
二、基于端口
a、创建另一个端口的测试网页
[root@localhost ~]# cd /var/www/html/ [root@localhost html]# echo "this is kgc 8080 web" > kgc/index.html
b、编辑nginx.conf配置文件,仅修改监听地址
server { listen 192.168.109.137:80; server_name www.accp.com; charset utf-8; access_log logs/www.accp.com.access.log ; location / { root /var/www/html/accp; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } server { listen 192.168.109.137:8080; server_name www.accp.com; charset utf-8; access_log logs/www.accp8080.com.access.log ; location / { root /var/www/html/accp8080; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } }
c、重载nginx服务
systemctl restart nginx netstat -ntap | grep 80
d、测试网页
www.accp.com
www.accp.com8080
三、基于IP
1、修改网页配置文件中的区域数据配置文件
vim /var/named/kgc.com.zone systemctl restart named
2、编辑nginx.conf中的配置,修改ip地址
server { listen 192.168.109.137:80; server_name www.kgc.com; charset utf-8; access_log logs/www.kgc.com.access.log ; location / { root /var/www/html/kgc; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } server { listen 192.168.109.134:80; server_name www.accp.com; charset utf-8; access_log logs/www.accp.com.access.log ; location / { root /var/www/html/accp; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } }
c、重载nginx服务
systemctl restart nginx netstat -ntap | grep 80
d、测试网页
192.168.109.137 192.168.109.134
总结
以上所述是小编给大家介绍的基于域名、端口和IP搭建nginx虚拟主机,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对网站的支持!
如果你觉得本文对你有帮助,欢迎转载,烦请注明出处,谢谢!
神剑山庄资源网 Design By www.hcban.com
神剑山庄资源网
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
神剑山庄资源网 Design By www.hcban.com
暂无基于域名、端口和IP搭建nginx虚拟主机的评论...
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。
更新日志
2024年09月21日
2024年09月21日
- 玩家吐槽《黑神话:悟空》唐僧相貌:一脸衰样 没半点气质
- 群星.1994-烧得厉害VOL.2我不是一个人拙滚石】【WAV+CUE】
- 群星.1994-烧得厉害VOL.3风笑痴【滚石】【WAV+CUE】
- 群星.1995-烧得厉害VOL.4两个世界【滚石】【WAV+CUE】
- 归龙潮中浦城区宝箱位置收集大全 中浦区宝箱解密攻略
- 黑神话悟空上品幽灯鬼精魄获取方法一览|上品幽灯鬼精魄收集攻略
- 《电锯糖心:RePOP》发售首日表现亮眼,玩家峰值超越《星鸣特攻》
- NewViennaOctet,ViennaWindSoloists-TheDeccaRecordings(2024)18CD[FLAC]-8
- 金梅子-《靓声妹3又见炊烟》[WAV+CUE]
- 杨阳《约定HQCDII》头版限量编号2024[WAV+CUE]
- 曝《黑神话:悟空》DLC明年推出 农历新年前后
- PS5日本涨价19% 索尼股价应声上涨2.7%
- 《黑神话》发行平台遭大规模网攻 外媒却鲜有报道
- 伍佰《爱你伍佰年 世纪典藏原音精选3CD》[WAV+CUE][2.3GB]
- 伍佰《爱情的尽头》[WAV+CUE][2.6GB]