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://lszwz.com/article/ispcio.html

其他资讯

售后响应及时

7×24小时客服热线

数据备份

更安全、更高效、更稳定

价格公道精准

项目经理精准报价不弄虚作假

合作无风险

重合同讲信誉,无效全额退款