一.安裝環境
推薦購買騰訊雲活動的輕應用服務器 2C2G 就可以啦,我買的是 45 一年的:點我購買
以下命令默認在 ubuntu 系統上執行
安裝 nginx
apt-get install nginx
mkdir /wwwroot/blog
生成博客
hexo deploy
然後把 public 文件夾打包,並上傳到服務器上,然後解壓博客到 /wwwroot/blog
目錄下。
└── blog
├── 404.html
├── about
│ └── index.html
├── archives
│ ├── 2022
│ │ ├── 06
│ │ │ └── index.html
│ │ ├── 07
│ │ │ └── index.html
│ │ └── index.html
│ └── index.html
├── index.html
配置 nginx
vim /etc/nginx/conf.d/blog.conf
server {
listen 80;
server_name <配置你的目錄>;
root /wwwroot/blog;
error_page 404 = /404.html;
access_log off;
location / {
index index.html;
}
}
保存後執行 nginx -s reload
命令就可以訪問啦。
二.啓用 CDN 和 HTTPS
使用騰訊雲 CDN https://console.cloud.tencent.com/cdn
免費證書:https://console.cloud.tencent.com/ssl
因爲是靜態博客,默認會全部緩存,所以發佈了新博客,或者對博客有了更改,需要刷新才能看到效果:https://console.cloud.tencent.com/cdn/refresh