首先第一步, 当然是先在本地搭建好hugo
配置nginx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
server {
listen 443 ssl default_server;
listen [::]:443 ssl default_server;
root /var/www;
ssl on;
ssl_certificate /etc/ssl/certs/llinx.me.pem;
ssl_certificate_key /etc/ssl/private/llinx.me.key;
ssl_dhparam /etc/ssl/certs/dhparam.pem;
index index.html index.htm index.nginx-debian.html;
server_name llinx.me;
location / {
try_files $uri $uri/ =404;
}
}
server {
listen 80;
server_name llinx.me;
rewrite ^(.*) https://$server_name$1 permanent;
}
|
配置HTTPS
https://llinx.me/post/automatic-issuance-and-renewal-of-acmesh-using-ssl/
配置git
1
2
3
4
5
6
7
8
|
apt install git -y
cd ~
mkdir llinx.me.git
cd llinx.me.git
git init --bare
cd hooks
touch post-receive
vi post-receive
|
使用以下脚本
1
2
3
4
5
6
7
8
|
#!/bin/sh
GIT_REPO=/root/llinx.me.git
TMP_GIT_CLONE=/tmp/blog
NGINX_HTML=/var/www
rm -rf ${TMP_GIT_CLONE}
git clone $GIT_REPO $TMP_GIT_CLONE
rm -rf ${NGINX_HTML}/*
cp -rf ${TMP_GIT_CLONE}/* ${NGINX_HTML}
|
:wq
设置本地git(Source Tree)
配置SSH
1
2
3
|
cd ~
mkdir .ssh
vi ~/.ssh/authorized_keys
|
设置权限
1
2
|
chmod 600 authorized_keys
chmod 700 -R .ssh
|
测试ssh连接
如果无需密码登陆那么进行下一步
Source Tree 添加远端为
1
|
ssh://root@IP:PORT/root/llinx.me.git
|
选项中设置密钥为id_rsa (私钥)
修改hugo设置并推送
主要是baseurl
,因为一般在本地使用的时候也不会去搞https的
存放其他文件
为保证其他文件不丢失,那么可以把public加入忽略,然后把整个博客目录推送到github上或者其他代码托管服务上