首页 > 其他 > 详细

NGINX VHOST配置文件的使用 之四

时间:2018-07-16 17:55:44      阅读:204      评论:0      收藏:0      [点我收藏+]
1、vhost配置文件的作用

作用:vhost配置文件的作用是为了将多个server配置文件的信息,单独存放,不过于集中在nginx.conf配置中,这样有用助于故障排除,如配置查看

2、创建vhost文件更夹,并指定加载方法

[root@localhost conf]# pwd
/app/nginx-1.6.3/conf
[root@localhost conf]# mkdir vhost
[root@localhost conf]# vi /app/nginx-1.6.3/conf/nginx.conf          #修改nginx.conf的配置文件,增加include目录

worker_processes  1;
events {
        worker_connections  1024;
}
http {
        include       mime.types;
        default_type  application/octet-stream;
        sendfile        on;
        keepalive_timeout  65;
        include vhost/*.conf;                       #增加内容,当nginx启动时,加载vhost目录下的所有conf文件
}

3、把原有nginx配置文件的server字段,复制到default.conf里

[root@localhost conf]# vi /app/nginx-1.6.3/conf/vhost/default.conf
server {
    listen       80;
    server_name  localhost;
    location / {
        root   html;
        index  index.html index.htm;
    }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }
}

备注:后面的server字段的配置文件,就可以在vhost新建conf文件就可以。

NGINX VHOST配置文件的使用 之四

原文:http://blog.51cto.com/12965094/2144965

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!