一、域名指向的虚拟机
1、修改配置文件,分别创建以域名www.kang.com与bbs.kang.com为监听对象网站
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen www.kang.com; #监听www.kang.com
server_name localhost;
location / {
root html/www; #该网站所在根目录
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 80;
server_name bbs.kang.com; #监听bbs.kang.com
location / {
root html/bbs; #该网站所在根目录
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
2、测试域名访问是否正常
[root@localhost nginx-1.6.3]# mkdir html/www
[root@localhost nginx-1.6.3]# mkdir html/bbs
[root@localhost nginx-1.6.3]# echo "www" html/www/index.html
www html/www/index.html
[root@localhost nginx-1.6.3]# echo "bbs" html/bbs/index.html
bbs html/bbs/index.html