一台服务器开多个网站  / 网络研习社#60

一台服务器开多个网站 / 网络研习社#60

nginx.jpg

随着需要的网站增多,域名也多了起来。刚开始一个域名开一台服务器,但现在这种情况明显有点不合实际了,毕竟服务器成本不低。那么,一台服务器上如何开多个网站?答案是nginx!

域名解析自不必去说,conf的设置改动一下就可以啰。比如都在监听80端口,以server_name和root来引导进不同的网站(如下文所示),是不是很轻松写意?!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
server {
listen 80;
server_name www.steemjiang.com;

location / {
root /home/steemjiang;
index index.html index.htm;
}
}

server {
listen 80;
server_name api.steemjiang.com;

location / {
root /home/api;
index index.html index.htm;
}
}

This page is synchronized from the post: ‘一台服务器开多个网站 / 网络研习社#60’

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×