今天整理了下,在centos 6.9 系統下怎麼配置多個conf文件。 step 1:在nginx.conf文件所在目錄新建conf.d目錄,即mkdir conf.d,為確保許可權能夠訪問到,so chmod 777 conf.d step 2:編輯nginx.conf文件,內容為: #user n ...
今天整理了下,在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:瀏覽器輸入地址訪問