一:Nginx虚拟主机
1.基于ip的方式
[root@web01 conf.d]# cat game2.conf
server {
listen 80;
server_name 192.168.15.7;
location / {
root /opt/Super_Marie;
index index.html;
}
}
server {
listen 80;
server_name 172.16.1.7;
location / {
root /opt/tank;
index index.html;
}
}
2、基于多端口的方式
[root@web01 conf.d]# cat game3.conf
server {
listen 80;
server_name 192.168.15.7;
location / {
root /opt/Super_Marie;
index index.html;
}
}
server {
listen 81;
server_name 192.168.15.7;
location / {
root /opt/tank;
index index.html;
}
}
3、基于多域名的方式
[root@web01 conf.d]# cat game4.conf
server {
listen 80;
server_name www.game.com;
location / {
root /opt/Super_Marie;
index index.html;
}
}
server {
listen 80;
server_name www.game1.com;
location / {
root /opt/tank;
index index.html;
}
}