查看nginx安装路径 whereis nginx
在/usr/local/nginx/conf目录下nginx.conf文件是nginx的配置文件
root虚拟主机的根目录
一个server标签就是一个虚拟主机
1.通过端口号区分虚拟机 在nginx.conf配置文件中添加server,修改端口号
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
}
server {
listen 81;
server_name localhost;
location / {
root html81;
index index.html index.htm;
}
}
2.通过域名区分虚拟机 一样都是修改配置文件
修改文件内容
修改之后重新加载配置文件