环境:hexo+next主题+阿里云ubuntu 22.04,本篇文章主要是记录在部署过程中遇到的一些在hexo和next教程中没有详细说明的情况,希望对大家有所帮助。
iterm2上设置代理
1 2 3 4 5 6 7 8 9 10 11 12 13
| export http_proxy=http://127.0.0.1:7890 export https_proxy=$http_proxy
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
unset http_proxy https_proxy
vim ~/.zshrc alias goproxy='export http_proxy=http://127.0.0.1:7890 https_proxy=http_proxy' alias disproxy='unset http_proxy https_proxy' source ~/.zshrc
|
给oh my zsh安装代理插件
zsh-proxy代理插件
Mac上开代理的情况下使用npm命令
vim /user/xia0sheng/.npmrc
1 2 3 4 5
| proxy = http://127.0.0.1:7890/ https_proxy = http://127.0.0.1:7890/ strict-ssl = false ca = false registry = https://registry.npmmirror.com/
|
next darkmode主题不生效
原因是macbook本身没有开启深色模式
ubuntu 22.04相关配置
Initial Server Setup with Ubuntu 22.04
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| apt update -y apt upgrade -y
apt install git git config --global user.name "xia0sheng" git config --global user.email "wangyouyu6@163.com" git config --global init.defaultBranch main
apt install nginx systemctl start nginx systemctl enable nginx
adduer git usermod -aG sudo git su git
sudo mkdir -p /var/www/hexo sudo chown -R $USER:$USER /var/www/hexo sudo chmod -R 755 /var/www/hexo
sudo mkdir repos && cd repos sudo git init --bare hexo.git
sudo vim post-receive
git --work-tree=/var/www/hexo --git-dir=/var/www/repos/blog.git checkout -f sudo chmod +x post-receive
sudo git init --bare /var/www/repos/hexo.git
su - chown -R git:git /var/www/repos/hexo.git/
vim /var/www/repos/hexo.git/hooks/post-receive git --work-tree=/var/www/hexo --git-dir=/var/www/repos/hexo.git checkout -f
chmod +x /var/www/repos/hexo.git/hooks/post-receive
ssh-copy-id -i ~/.ssh/id_rsa.pub git@wangyouyu.com
ssh git@wangyouyu.com
|
修改_config.yml
1 2 3 4 5 6 7 8
|
deploy: - type: git repo: github: git@github.com:xia0sheng/blog,main aliyun: git@wangyouyu.com:/var/www/repos/hexo.git,main - type: leancloud_counter_security_sync
|
提交部署
1
| hexo clean && hexo g && hexo d
|
关于busuanzi不能正确统计uv和pv的问题
如果域名不是https,那么busuanzi统计会有问题,pv和uv同时增加
网站添加ssl证书
官方教程:certbot自动添加证书并更新
digitalocean教程:How To Secure Nginx with Let’s Encrypt on Ubuntu 20.04
Issue with non www and www redirect to www with https in Nginx
Goal: to redirect each of the 3 non-https://@ options into one secure @. In other words, http://www.example.com, http://example.com, https://www.example.com should ALL redirect to https://example.com – but without the IF’s.
https://www.digitalocean.com/community/questions/issue-with-non-www-and-www-redirect-to-www-with-https-in-nginx
Remove example.com from server_name directive and create a new server block
最终nginx配置如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| server {
root /var/www/hexo; index index.html index.htm index.nginx-debian.html; server_name wangyouyu.com;
location / { try_files $uri $uri/ =404; }
listen 443 ssl; ssl_certificate /etc/letsencrypt/live/wangyouyu.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/wangyouyu.com/privkey.pem; include /etc/letsencrypt/options-ssl-nginx.conf; ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}
server { listen 443; listen [::]:443 ipv6only=on; server_name www.wangyouyu.com; ssl_certificate /etc/letsencrypt/live/wangyouyu.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/wangyouyu.com/privkey.pem; include /etc/letsencrypt/options-ssl-nginx.conf; ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; return 301 https://wangyouyu.com$request_uri;
}
server { if ($host = www.wangyouyu.com) { return 301 https://$host$request_uri; }
if ($host = wangyouyu.com) { return 301 https://$host$request_uri; }
server_name wangyouyu.com www.wangyouyu.com; listen 80; return 404;
}
|
证书部署测试
https://www.ssllabs.com/ssltest/
wangyouyu.com
www.wangyouyu.com
https://wangyouyu.com
https://www.wangyouyu.com
Hexo设置 read more 即“阅读全文”
在文章正文摘要部分后面插入 <!-- more -->

解决:[Disqus API Application] 里website里填写的域名为http开头,改为https就可以了