惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

量子位
Vercel News
Vercel News
Microsoft Azure Blog
Microsoft Azure Blog
爱范儿
爱范儿
N
Netflix TechBlog - Medium
Google DeepMind News
Google DeepMind News
H
Help Net Security
罗磊的独立博客
The Cloudflare Blog
J
Java Code Geeks
博客园 - 叶小钗
I
InfoQ
B
Blog
Blog — PlanetScale
Blog — PlanetScale
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
腾讯CDC
月光博客
月光博客
博客园_首页
雷峰网
雷峰网
M
MIT News - Artificial intelligence
博客园 - 【当耐特】
美团技术团队
T
The Blog of Author Tim Ferriss
博客园 - 司徒正美

OhYee 博客

小鹏辅助驾驶测评|OhYee 博客 小鹏非支持手机开启自动解锁|OhYee 博客 使用函数计算实现 301 重定向|OhYee 博客 针对 HTML 内容使用 Ant Design 图片弹框|OhYee 博客 博客进程泄露及僵尸进程解决|OhYee 博客 蓝易云服务器体验|OhYee 博客 SSH 调起本地 VSCode|OhYee 博客 【2022 秋招内推】阿里云后端研发工程师|OhYee 博客 使用函数计算获取 IP 地址信息|OhYee 博客 正确获取客户端 IP/HTTP Header 也可能重复|OhYee 博客 评测 Oculus Quest2 及 BigScreen|OhYee 博客 NextJS 热重载保留状态|OhYee 博客 如何优雅地贴 gist 代码|OhYee 博客 Linux 精细化文件权限|OhYee 博客 VSCode 容器开发环境|OhYee 博客 Clash 的不兼容更新排查|OhYee 博客 Zeek 导出 PCAP|OhYee 博客 记一次 ssh 配置问题|OhYee 博客 Git Commit 规范化工具|OhYee 博客 谈谈《星之卡比-探索发现》|OhYee 博客 VSCode 快捷键绑定 Shell 命令|OhYee 博客 ASN.1 语法及 X.509 证书格式解析解析|OhYee 博客 腾讯企业邮箱忽略 MX 记录发信|OhYee 博客 Chrome/Edge 标签组插件|OhYee 博客 【应届内推】阿里云后端研发工程师|OhYee 博客 损坏的 Typecho 备份处理为 JSON|OhYee 博客 VS Code VIM 插件高效使用|OhYee 博客 SSH 正反向代理|OhYee 博客 Let's Encrypt 根证书过期引发的问题|OhYee 博客 OpenWRT 忽略内核依赖|OhYee 博客
部署 Blotter 博客系统|OhYee 博客
2020-06-05 · via OhYee 博客

部署 Blotter 博客系统

由于换小号嫖腾讯云 618 活动,因此要把服务器上的博客迁移一下,顺便做一下部署笔记

环境配置

Blotter 需要的内容有:Python、Go、Java、Node.JS、Yarn、MongoDB、GraphViz、PlantUML、Git

sudo apt update
sudo apt install python3.8 python3-pip nodejs npm graphviz plantuml git nginx screen -y
sudo npm -g install n
sudo n stable
sudo npm -g install yarn

wget https://dl.google.com/go/go1.14.4.linux-amd64.tar.gz
sudo tar -xzvf go1.14.4.linux-amd64.tar.gz -C /usr/local
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct
export PATH=$PATH:/usr/local/go/bin

echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.2.list
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4B7C549A058F8B6B
sudo apt-get update
sudo apt-get install -y mongodb-org

python3.8 -m pip install pymongo feedparser bs4 lxml --user

安装 Blotter

git clone https://gitee.com/OhYee/blotter.git
git clone https://gitee.com/OhYee/blotter_page.git -b gh-pages
cd blotter && go build && cd ..
cd blotter_page && yarn && cd ..

配置 Nginx

在这里可能还需要配置nginx.conf的启动用户为static文件的用户,如User ubuntu

如果需要配置 WASM,则还需要在mime.types中添加application/wasm wasm;

server {
    listen       80;
    server_name www.oyohyee.com;
    rewrite ^(.*)$ https://$host$1 permanent;
}

map $http_upgrade $connection_upgrade{
        default upgrade;
        '' close;
}

server {
    listen       443 ssl http2 default_server;
    server_name www.oyohyee.com;

    client_max_body_size 20m;

    ssl_certificate "/etc/nginx/ssl/1_www.oyohyee.com_bundle.crt";
    ssl_certificate_key "/etc/nginx/ssl/2_www.oyohyee.com.key";
    ssl_session_cache shared:SSL:1m;
    ssl_session_timeout  10m;
    ssl_ciphers HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers on;

    proxy_max_temp_file_size 0;


    location ^~ / {
        #root   /usr/share/nginx/html;
        #index  index.html index.htm;
        proxy_pass  http://127.0.0.1:50002;
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Scheme $scheme;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-Host $server_name;
    }
    location ^~/static/ {
        root /home/ubuntu/blog/;
    }
    location ^~/api/ {
        proxy_pass http://127.0.0.1:50000;
        proxy_set_header nginx true;
                proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
    }
    location = /ads.txt {
        root /home/ubuntu/blog;
    }
    rewrite /sitemap.txt /api/sitemap.txt;
    rewrite /sitemap.xml /api/sitemap.xml;
    rewrite /rss.xml /api/rss.xml;
    rewrite /robots.txt /api/robots.txt;
}

配置定时任务

0 * * * * bash /home/ubuntu/blog/autopush
30 3 * * * bash /home/ubuntu/blog/autobackup
0 3 * * * bash /home/ubuntu/blog/spider

百度主动推送

#!/bin/bash
curl https://www.oyohyee.com/sitemap.txt > /home/ubuntu/blog/urls.txt
curl -H 'Content-Type:text/plain' --data-binary @/home/ubuntu/blog/urls.txt "http://data.zz.baidu.com/urls?site=www.oyohyee.com&token=Ah36uCNcnwq2q7LX"

每日备份

#!/bin/bash
mongodump -o /home/ubuntu/blog/backup/`date '+%Y_%m_%d'`

爬虫更新

#!/bin/bash
python3.8 /home/ubuntu/blog/blotter/spider/main.py >> spider.txt

开放 25 端口

控制台开放对应服务器的端口用于发送邮件

参考文章