网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

Nginx虚拟机怎么安装和使用

这篇文章主要介绍Nginx 虚拟机怎么安装和使用,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

创新互联专注于乾安企业网站建设,响应式网站,商城网站制作。乾安网站建设公司,为乾安等地区提供建站服务。全流程按需网站设计,专业设计,全程项目跟踪,创新互联专业和态度为您提供的服务

在Nginx 虚拟机中用多个子域名,每个子域名到不同的目录。

如:

http {   server {   listen 80;   server_name a.chenlb.com;   access_log logs/a.access.log main;   server_name_in_redirect off;   location / {   index index.html;   root /home/www/host_a/;   }   }   server {   listen 80;   server_name b.chenlb.com;   access_log logs/b.access.log main;   server_name_in_redirect off;   location / {   index index.html;   root /home/www/host_b/;   }   }   }   http {  server {  listen 80;  server_name a.chenlb.com;  access_log logs/a.access.log main;  server_name_in_redirect off;  location / {  index index.html;  root /home/www/host_a/;  }  }  server {  listen 80;  server_name b.chenlb.com;  access_log logs/b.access.log main;  server_name_in_redirect off;  location / {  index index.html;  root /home/www/host_b/;  }  }  }

结果发现用 b.chenlb.com 还是指到 host_a 目录。后来看了官方示例:http://wiki.Nginx.org/NginxVirtualHostExample,提到有个 default 的匹配,如:

http {   server {   listen 80 default;   server_name _;   access_log logs/default.access.log main;   server_name_in_redirect off;   location / {   index index.html;   root /var/www/default/htdocs;   }   }   }   http {  server {  listen 80 default;  server_name _;  access_log logs/default.access.log main;  server_name_in_redirect off;  location / {  index index.html;  root /var/www/default/htdocs;  }  }  }

加上这个 default 就可使 a.chenlb.com 和 b.chenlb.com 正常工作了。

以上是“Nginx 虚拟机怎么安装和使用”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注创新互联行业资讯频道!


网站题目:Nginx虚拟机怎么安装和使用
网站路径:http://bjjierui.cn/article/ispcio.html

其他资讯