Just relax, take it easy..

0%

部署 Hexo 静态博客 (上) - Google Cloud Platform OSS 之旅

众所周知, 要使用国内的云服务, 不管是 vps 也好, cdn 加速也好, 域名都是要备案的. 但对于我来说, 备案是不可能备案的,这辈子不可能备案的.

正好前段时间工作中接触了 aliyun 的 oss, 就萌生了将网站部署到 Google Cloud Platform 的 OSS 上的想法💡.

结论:
GCP 的 OSS 速度看上去还是很优秀的, 但部署步骤繁琐, https 比较棘手, 还是放弃了这种部署方式.
最终选择了 Netlify, 见下一篇博客:

新建 bucket

验证对网站的所有权

创建前要先在 search console 中验证这个网站是你的, 验证链接 .
有很多种验证的方法, 如果你使用的是 hexo 的 next 主题, 可以在 _config.yml 中配置 google_site_verification 字段就 ok 了.

注意 bucket 的名字

如果要 serve 静态网站的话, 名字要和域名保持一致.

地区:

记得地区选 Asia 哟.

上传文件

gsutil 安装

安装 gsutil
pip install gsutil
不支持 python3???

gsutil 简易版步骤

创建 bucket(或者手动创建, 这个不知道如何定制地区)
gsutil mb gs://www.hypers.me
全部 bucket 的权限默认为公共读:
gsutil defacl set public-read gs://www.hypers.me
上传文件:
gsutil rsync -R local-dir gs://www.example.com
设置 index&404:
gsutil web set -m index.html -e 404.html gs://www.hypers.me

配置 DNS, 添加 CNAME 记录

文档: https://cloud.google.com/storage/docs/hosting-static-website?hl=en_US&_ga=2.265398415.-1885452353.1527271271

1
2
NAME                  TYPE     DATA
www.example.com CNAME c.storage.googleapis.com.

测速

GCP OSS(左) VS Aliyun 香港 OSS(右)

GCP OSS(左) VS Aliyun 香港 ECS(右)

https

文档: https://cloud.google.com/storage/docs/troubleshooting#https
提供了三种解决方案:

要哭了 T^T

reference: