nginx配置多个conf文件

今天整理了下,在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:浏览器输入地址访问

你可能感兴趣的:(原创,java)