[iyunv@centos1 conf.d]# cd /etc/nginx/conf.d/
[iyunv@centos1 conf.d]# ls
default.conf ssl.conf virtual.conf
配置virtual.conf,添加虚拟主机。
server {
listen 81;
server_name 192.168.1.111;
location / {
root /usr/local/download;
index index.html index.htm;
}
}
这是基于端口的虚拟主机。
进行nginx语法检查:
[iyunv@centos1 conf.d]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful