在/usr/local/nginx/conf目錄下nginx.conf文件是nginx的配置文件。

一、通過端口號區分虛擬機
在nginx.conf文件中添加一個Service節點,修改端口號:
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html80;
index index.html index.htm;
}
}
server {
listen 81;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html81;
index index.html index.htm;
}
}
二、通過域名區分虛擬機
①:需要修改nginx.conf配置文件
server {
listen 80;
server_name test1.nginx.com;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html-test3;
index index.html index.htm;
}
}
server {
listen 80;
server_name test2.nginx.com;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html-test3;
index index.html index.htm;
}
}
②:修改后重新加載配置文件
[root@localhost sbin]# ./nginx -s reload
至此結束……

關注我的公眾號,精彩內容不能錯過
