Git, Hexo on CentOS were used to build this blog. Some updates on the bottom.
SSL certification need to be renewed by Let’s Encrypt.
Now actually Git is not being used. For statical page, it is not very problematic…
#Log
Switch from WordPress system to a new blog system Hexo.
Check Hexo documentation for more info.
Online action includes Nginx, ssl certificate and git hexo installation.
Hostname, Nginx
CentOS 7 from Vultr.com
Install git and Nginx:
1 | yum -y update |
1 | vi /index.html |
1 | <!DOCTYPE html> |
1 | vi /etc/nginx/nginx.conf |
1 | server { |
Port 80 with http done.
SSL certification - Let’ s Encrypt
Using certbot by Let’s Encrypt:
1 | yum install certbot |
then obtain the ssl certificate:
1 | mkdir -p /.well-known/acme-challenge |
To renew the certificate using
1 | certbot renew |
or automatically
1 | vi /etc/crontab |
1 | 0 23 28 * * root certbot renew --quiet --deploy-hook "systemctl restart nginx" |
1 | crontab /etc/crontab |
Then we need to add the ssl certificate in Nginx:
1 | vi /etc/nginx/nginx.conf |
1 | server{ |
done.
1 | systemctl restart nginx |
Now we can use ssl https to visit our index. on your host name or ip address.
Hexo installation on CenOS
initial git lib:
1 | mkdir /GitLibrary |
then configure the hook:
1 | vi /GitLibrary/hexo.git/hooks/post-update.sample |
add
1 | git --work-tree=/ --git-dir=/GitLibrary/hexo.git checkout -f |
and then
1 | mv post-update.sample post-update |
in some cases post-receive instead of post-update.
Now we finish jobs at server to deploy Hexo. But I still want to add shadowsocks to set up VPN as well as Blog on my server.
Shadowsocks
install shadococks, below git install may be already done:
1 | yum install python-setuptools |
create shadowsocks service:
1 | vi /usr/lib/systemd/system/shadowsocks.service |
1 | [Unit] |
create the directory /usr/share/nginx/etc/ if not exist
1 | vi /usr/share/nginx/etc/shadowsocks.json |
and write:
1 | { |
notice we choose aes-256-gcm encryption method here.
then run it
1 | systemctl enable shadowsocks |
Hexo in my mac
Important: git and node.js are prerequisite.
Then Hexo installation (we install blog system in ~/Blog):
1 | npm install hexo-cli hexo-server hexo-deployer-git -g |
in the configuration file _config.yml:
1 | # URL |
and you can specify your host name, to create CNAME in the /blog/source and write XXX.com.
Then using
1 | hexo clean |
we can check our blog offline.
To deploy to the remote server:
1 | hexo deploy |
visit your XXX.com : )
Trouble shot
- Firewall block
CentOS 7 using firewalld and may block some port, to disable firewall, use
1 | systemctl stop firewalld |
- SSH key in your PC
1 | ssh-keygen |
Or you can find the key upload in your Vultr.com console…
Reference and many thanks
Update on the 2019/10/13
重装系统后懒得在服务器上安装git了(其实就是不想再折腾了,印象中挺麻烦的)
每次直接scp /public 文件夹就完了