码迷,mamicode.com
首页 > 其他好文 > 详细

nginx配置多个conf文件

时间:2018-07-27 18:07:14      阅读:281      评论:0      收藏:0      [点我收藏+]

标签:include   ica   push   location   root   time   server   cat   worker   

今天整理了下,在centos 6.9 系统下怎么配置多个conf文件。

step 1:在nginx.conf文件所在目录新建conf.d目录,即mkdir conf.d,为确保权限能够访问到,so chmod 777 conf.d

step 2:编辑nginx.conf文件,内容为:

#user nobody;
worker_processes 1;

error_log /usr/local/nginx/logs/error.log;
error_log /usr/local/nginx/logs/error.log notice;
error_log /usr/local/nginx/logs/error.log info;

#pid logs/nginx.pid;


events {
worker_connections 1024;
}


http {
include mime.types;
default_type application/octet-stream;

log_format main ‘$remote_addr - $remote_user [$time_local] "$request" ‘
‘$status $body_bytes_sent "$http_referer" ‘
‘"$http_user_agent" "$http_x_forwarded_for"‘;

access_log /usr/local/nginx/logs/access.log main;

sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;

#gzip on;
include /usr/local/nginx/conf/conf.d/*.conf;

}

step 3:在conf.d目录下随便写个.conf文件, 内容为:

server{
listen 8888;
server_name localhost;

 

location / {
root /usr/local/nginx/html;
index index.html index.htm;
}
}

step 4:测试下conf文件格式是否正确,nginx -t

step 5:启动nginx 

step 6:浏览器输入地址访问

 

nginx配置多个conf文件

标签:include   ica   push   location   root   time   server   cat   worker   

原文地址:https://www.cnblogs.com/freezehe/p/9378885.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!