码迷,mamicode.com
首页 > Web开发 > 详细

一个域名通过nginx映射多个网站

时间:2020-01-30 21:10:46      阅读:190      评论:0      收藏:0      [点我收藏+]

标签:file   cat   www   腾讯云   要求   etc   err   default   申请   

一.前提要求

1.拥有一个腾讯云云服务器

2.买有一个域名

3.域名通过备案(一般需要30天左右备案时间)

二.实现例子

1.博客网站对应blog.abc.com

2.项目网站对应demo.abc.com

3.个人简历对应www.abc.com

三.实现步骤

先通过A记录申请三个二级域名,分别为上面的三个。并且映射到你的云服务器公有IP。

通过nginx进行配置三个serve

server {
listen 80;
server_name blog.abc.com;
root /usr/share/nginx/blog;

# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;

location / {
}

error_page 404 /404.html;
location = /40x.html {
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}

 

server {
listen 80;
server_name demo.abc.com;
root /usr/share/nginx/demo;

# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;

location / {
}

error_page 404 /404.html;
location = /40x.html {
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}

 

server {
listen 80;
server_name www.abc.com;
root /usr/share/nginx/www;

# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;

location / {
}

error_page 404 /404.html;
location = /40x.html {
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}

最后配置完成后重启一哈nginx(nginx -s reload)即可访问。

一个域名通过nginx映射多个网站

标签:file   cat   www   腾讯云   要求   etc   err   default   申请   

原文地址:https://www.cnblogs.com/zhang1568234/p/12243458.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!