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://www.mswzjz.cn/qtweb/news19/235769.html
攀枝花网站建设、攀枝花网站运维推广公司-贝锐智能,是专注品牌与效果的网络营销公司;服务项目有等
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 贝锐智能