lemooljiang avatar

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

lemooljiang

Published: 09 Apr 2020 › Updated: 09 Apr 2020

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

nginx.jpg

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

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

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;
  }
}

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

Written by

Designer , Poet , Technology enthusiasts

Read more #cn posts


Best Posts From lemooljiang

We have not curated any of lemooljiang's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From lemooljiang