安装工具
| 12
 
 | apt updateapt -y install docker.io gdebi-core git npm
 
 | 
注意:docker.io 为评论后端所需,gdebi-core 用于安装 OSS 挂载工具,git 和 npm 是 Hexo 必备的工具。
评论后端
| 12
 3
 4
 5
 6
 7
 8
 
 | tee /etc/docker/daemon.json <<-'EOF'{
 "registry-mirrors": ["https://xxxxxxxx.mirror.aliyuncs.com"]
 }
 EOF
 systemctl restart docker
 docker run -d --restart=always -e MYSQL_HOST=HOSTNAME -e MYSQL_DB=DATABASE -e MYSQL_USER=USERNAME -e MYSQL_PASSWORD=PASSWORD -e SITE_NAME=懒猪说 -e SITE_URL=https://dusays.com -e IPQPS=0 -e SECURE_DOMAINS=dusays.com -e AKISMET_KEY=false -e AUTHOR_EMAIL=EMAILADDRESS -e SMTP_SERVICE=QQ -e SMTP_USER=EMAILADDRESS -e SMTP_PASS=PASSWORD -e GITHUB_ID=GITHUBID -e GITHUB_SECRET=GITHUBSECRET -p 8360:8360 lizheming/waline
 docker run -d --restart=always --name watchtower -v /var/run/docker.sock:/var/run/docker.sock containrrr/watchtower
 
 | 
注意:首先添加了阿里云的镜像加速器,加速 Docker 镜像的下载速度。然后运行评论后端,最后运行容器版本自动更新工具,感兴趣的可以参考《通过 Watchtower 实现 Docker 容器自动更新》一文。
挂载存储
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 
 | wget https://gosspublic.alicdn.com/ossfs/ossfs_1.80.6_ubuntu18.04_amd64.deb?spm=a2c4g.11186623.2.6.20e22315wihlec&file=ossfs_1.80.6_ubuntu18.04_amd64.debgdebi ossfs_1.80.6_ubuntu18.04_amd64.deb
 echo BucketName:yourAccessKeyId:yourAccessKeySecret > /etc/passwd-ossfs
 chmod 640 /etc/passwd-ossfs
 mkdir /dusays
 ossfs BucketName mountfolder -o url=Endpoint
 tee /etc/rc.local <<-'EOF'
 #!/bin/bash
 ossfs BucketName mountfolder -o url=Endpoint
 exit 0
 EOF
 chmod +x /etc/rc.local
 
 | 
注意:懒猪说运行于阿里云的 OSS,并通过 CDN 加速,故需安装并挂载 OSS。
安装程序
| 12
 
 | npm i -g hexo-clihexo init blog
 
 | 
注意:安装 Hexo 并生成博客目录。
相关模块
| 12
 
 | cd blog/npm i -S hexo-generator-baidu-sitemap hexo-generator-feed hexo-generator-json-content hexo-generator-search hexo-pdf hexo-wordcount
 
 | 
注意:进入博客目录,安装 Hexo 的相关模块。
下载文件
| 12
 3
 4
 5
 6
 
 | vim _config.yamlgit config --global http.proxy http://dusays.com
 git config --global user.email EMAILADDRESS
 git config --global user.name USERNAME
 git clone ssh://git@dusays.com/penndu/dusays.git source/
 git clone https://github.com/penndu/hexo-theme-volantis themes/volantis
 
 | 
注意:懒猪说的文章和模板都托管在 Git 上,通过 git clone 下载到服务器中。
添加缓存
| 12
 
 | echo '/swapfile none swap sw 0 0' > /etc/fstabswapon -a
 
 | 
注意:为了保障服务器系统的稳定,添加交换分区,如果添加失败,可以参考《初始化 CentOS7 系统「上篇」》一文。
生成页面
| 12
 
 | ln -s /dusays/ publichexo g
 
 | 
注意:将 OSS 挂载目录与 Hexo 页面生成目录建立链接,即可生成网站页面。
                                                本文链接:https://my.lmcjl.com/post/18537.html
                                                                                                
                                                                                             
                                            
                                        
4 评论