nginx域名配置虚拟主机
发表于:2026-10-31 作者:千家信息网编辑
千家信息网最后更新 2026年10月31日,一个域名,对应一个IP地址通过DNS域名解析服务器,可以将域名解析为IP地址这里通过修改host文件,指定域名的IP地址host劫持是指在host文件中,配置域名和IP地址,当访问域名的时候因为,ho
千家信息网最后更新 2026年10月31日nginx域名配置虚拟主机
一个域名,对应一个IP地址
通过DNS域名解析服务器,可以将域名解析为IP地址
这里
通过修改host文件,指定域名的IP地址
host劫持
是指在host文件中,配置域名和IP地址,当访问域名的时候
因为,host文件中已经有了域名所对应的IP地址
所以,不再需要访问DNS服务器进行解析,直接访问对应的IP地址
host文件的位置
C:\Windows\System32\drivers\etc
Nginx配置文件注释:
[root@localhost conf]# vim nginx.confworker_processes 1; #worker进程的数量events { #事件块的开始worker_connections 1024; #每个worker进程支持的最大连接数} #事件块的结束http { #HTTP区块的开始include mime.types; #Nginx支持媒体类型库文件default_type application/octet-stream; #默认的媒体类型sendfile on; #开启高速传输模式keepalive_timeout 65; #连接超时server { #第一个server区块的开始 listen 80; #提供服务的端口,默认为80 server_name www.nautilus.org ; #提供服务的域名主机 location / { #第一个location区块的开始 root html/www; #站点的根目录,相当于Nginx的安装目录 index index.html index.htm; #默认的首页文件,多个使用空格隔开 } #第一个location区块的结束 error_page 500 502 503 504 /50x.html; #出现对应的http状态码是,使用50x.html回应客户 location = /50x.html { #location区块的开始,访问50x.html root html; #指定对应的站点目录为html }}} #HTTP区块的结束操作步骤
[root@localhost nginx]# lsclient_body_temp fastcgi_temp logs sbin uwsgi_tempconf html proxy_temp scgi_temp[root@localhost nginx]# cd html[root@localhost html]#[root@localhost html]# mkdir www [root@localhost html]# [root@localhost html]# cd www[root@localhost www]# lsindex.html[root@localhost www]# vim index.html hello localhost[root@localhost nginx]# vim /etc/hosts127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4::1 localhost localhost.localdomain localhost6 localhost6.localdomain6172.31.1.32 www.nautilus.org访问网站:
www.nautilus.orgNginx配置基于多域名
server { listen 80; server_name www.nautilus.org; location / { root html/www; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; }} server { listen 80; server_name bbs.nautilus.org; location / { root html/bss; index index.html index.htm; }}server { listen 80; server_name blog.nautilus.org; location / { root html/blog; index index.html index.html; }}[root@localhost nginx]# cd html[root@localhost html]#[root@localhost html]# mkdir bbs [root@localhost html]# [root@localhost html]# cd bbs[root@localhost bbs]# lsindex.html[root@localhost bbs]# vim index.html hello bbs[root@localhost html]# mkdir blog [root@localhost html]# [root@localhost html]# cd blog[root@localhost blog]# lsindex.html[root@localhost blog]# vim index.html hello blog [root@localhost html]# ls50x.html bbs blog index.html www[root@localhost nginx]# vim /etc/hosts127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4::1 localhost localhost.localdomain localhost6 localhost6.localdomain6172.31.1.32 www.nautilus.org172.31.1.32 bbs.nautilus.org172.31.1.32 blog.nautilus.org访问网站:
www.nautilus.org bbs.nautilus.org blog.nautilus.org
域名
区块
地址
文件
服务
配置
事件
媒体
服务器
目录
站点
类型
网站
进程
支持
主机
最大
位置
域名主机
多个
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
深圳市人人互联网科技有限公司
广东万易互联网科技有限公司惠州分公司
互联网是第几次科技革命的成果
互联网和科技技术
互联网最新的科技有限公司
奇酷互联网科技公司
壕鑫互联网络科技
互联网科技logo
上海亿帐通互联网科技
哈尔滨新华互联网科技
互联网公司会议桌创意科技软装饰
北京三清互联网科技
西藏七维空间互联网科技有限公司
中国的互联网科技企业的崛起
中国互联网有什么科技含量
团飞科技与伯堂互联网服务平台
合肥互联网科技公司公章图片
山东子淼互联网科技有限公司
厦门江牛科技互联网
重庆科技产业互联网有哪些
互联网科技企业
互联网科技会
科技与互联网发展
艾特科技互联网
壹账通互联网科技
顺玮阁互联网科技
互联网科技热点资讯
金融科技与互联网金融相同和不同
上海创道互联网络科技有限公司
互联网科技大佬云集