找到Nginx 配置文件(nginx version: nginx/1.12.2)
路徑:/usr/local/nginx/conf/nginx.conf
操作:在 http 模塊增加(子配置文件的路徑和名稱(chēng)):include vhost/*.conf;
user root;
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 vhost/*.conf;
}
配置Nginx 的子配置文件
路徑:/usr/local/nginx/conf/vhost
1 2 | [root@VM_2_29_centos vhost] # ls 35e.net.conf wa2.net.conf |
子配置文件例子:對于 http,直接 把想要的域名 加載 server_name 后面,空格間隔;對于 https, 要配 ssl 證書(shū)路徑,需要復制一份修改下 server_name 和 ssl 證書(shū)位置就OK了。