一.前提要求
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)即可訪問。