优化配置目录
创建conf.d
[root@localhost conf]# pwd
/usr/local/nginx/conf
[root@localhost conf]# mkdir conf.d
[root@localhost conf]# ll
total 60
drwxr-xr-x. 2 root root 6 Oct 23 06:48 conf.d
-rw-r--r--. 1 root root 1077 Oct 20 07:00 fastcgi.conf
-rw-r--r--. 1 root root 1077 Oct 20 07:00 fastcgi.conf.default
-rw-r--r--. 1 root root 1007 Oct 20 07:00 fastcgi_params
-rw-r--r--. 1 root root 1007 Oct 20 07:00 fastcgi_params.default
-rw-r--r--. 1 root root 2837 Oct 20 07:00 koi-utf
-rw-r--r--. 1 root root 2223 Oct 20 07:00 koi-win
-rw-r--r--. 1 root root 3957 Oct 20 07:00 mime.types
-rw-r--r--. 1 root root 3957 Oct 20 07:00 mime.types.default
-rw-r--r--. 1 root root 3286 Oct 22 03:08 nginx.conf
-rw-r--r--. 1 root root 2656 Oct 20 07:00 nginx.conf.default
-rw-r--r--. 1 root root 636 Oct 20 07:00 scgi_params
-rw-r--r--. 1 root root 636 Oct 20 07:00 scgi_params.default
-rw-r--r--. 1 root root 664 Oct 20 07:00 uwsgi_params
-rw-r--r--. 1 root root 664 Oct 20 07:00 uwsgi_params.default
-rw-r--r--. 1 root root 3610 Oct 20 07:00 win-utf
修改nginx.conf
http模块中新增include /usr/local/nginx/conf/conf.d/*.conf
,把conf.d
目录下的conf文件包含进来
[root@localhost conf]# vim nginx.conf
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log 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 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
}
创建proxy.conf
进入conf.d目录下创建proxy.conf文件
[root@localhost conf.d]# pwd
/usr/local/nginx/conf/conf.d
server {
listen 80;
server_name localhost;
location /{
root html/domain;
index index.html index.htm;
}
}
运行nginx
[root@localhost sbin]# ./nginx
网友评论