1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
[root@web www]
# vim /etc/nginx/nginx.conf
server {
listen 80;
server_name www.nginx.com;
location / {
root
/data/www
;
index index.html index.htm;
}
}
server {
listen 80;
server_name www.
test
.com;
location / {
root
/data/test
;
index index.html index.htm;
}
}
|
1
2
3
4
|
[root@web data]
# mkdir test
[root@web data]
# cd test/
[root@web
test
]
# cat index.html
<h1>www.
test
.com<
/h1
>
|
1
2
3
4
|
[root@web run]
# service nginx reload
nginx: the configuration
file
/etc/nginx/nginx
.conf syntax is ok
nginx: configuration
file
/etc/nginx/nginx
.conf
test
is successful
重新载入 nginx: [确定]
|
1
2
3
4
|
Windows 7下路径:C:\Windows\System32\drivers\etc\hosts
增加两行:
192.168.18.201 www.nginx.com
192.168.18.201 www.
test
.com
|
访问www.nginx.com ,展示/data/www/index.html
访问www.test.com ,展示/data/test/index.html