欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

linux服务之nginx-随笔-4(nginx配置文件规范化配置)

程序员文章站 2022-06-11 14:55:06
...
一、创建扩展目录
mkdir /application/nginx/conf/extra -p

二、创建不同的站点配置文件
   sed -n '10,17p' /application/nginx/conf/nginx.conf >/application/nginx/conf/extra/www.conf
   sed -n '18,25p' /application/nginx/conf/nginx.conf >/application/nginx/conf/extra/bbs.conf
   sed -n '26,33p' /application/nginx/conf/nginx.conf >/application/nginx/conf/extra/blog.conf 

三、利用nginx.conf主配置文件调用虚拟主机配置文件
   [[email protected] conf]# cat nginx.conf
   worker_processes  1;
   events {
       worker_connections  1024;
   }
   http {
       include       mime.types;
       default_type  application/octet-stream;
       sendfile        on;
       keepalive_timeout  65;
       include      extra/www.conf;
       include      extra/bbs.conf;
       include      extra/blog.conf;
   }



#说明:配置文件我这里写的相对路径,也可以写绝对路径

   nginx -t && nginx -s reload
   说明:当调用扩展配置文件是,如果指定*,会按照文件列表信息读取虚拟主机内容 从上到下的顺序读取