部署 PurePress 静态博客

之前逛 GitHub 无意间看见 rc大佬博客,感觉非常简洁好看,就决定把自己的博客迁移至 PurePress

环境

Python >= 3.6

Pipit >= 0.8.0

初始化

安装模块 PurePress

pip3 install purepress

新建一个文件夹 blog,用于存放「博客」文件。

mkdir blog

切换至该目录。

cd blog

初始化「博客」。

purepress init

提示OK! Now you can install a theme and preview the site.,说明初始化成功。

安装一个主题,个人比较喜欢 Minimal,就用这个了。

git clone https://github.com/verilab/purepress-theme-minimal theme

修改「博客」网站信息。

vim purepress.toml

构建「博客」。

purepress build

提示OK! Now you can find the built site in the "build" folder.,说明构建成功。

部署

安装「nginx」。

apt install nginx

运行「nginx」,生成一次配置文件。

service nginx start

修改 /etc/nginx/nginx.conf,否则「nginx」无法访问root目录。

user www-data; -> user root;

添加一个站点,在 /etc/nginx/sites-available/ 中新建一个文件 blog,并填写以下内容:

server {
        listen 80;  # 监听端口
        listen [::]:80;  # 监听端口

        root /root/blog/build;  # 网站文件目录
        index index.html;

        server_name www.domain.com;  # 网站域名

        location / {
                try_files $uri $uri/ =404;
        }
}

启用该站点。

ln -s /etc/nginx/sites-available/blog /etc/nginx/sites-enabled/blog

重新启动「nginx」。

service nginx restart

访问网站 http://填写的域名/

example

🎉大功告成🎉

评论