Isso是一款开源的评论系统,小巧功能多,这边文章记录一下部署过程,记录遇到的坑。我的linux是CentOS7.5 64位。
Install pip
如果你还未安装,则可以使用以下方法来安装:
1$ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py # 下载安装脚本
2$ sudo python get-pip.py # 运行安装脚本
Install isso
1$ sudo yum install python-devel sqlite
2$ sudo yum groupinstall “Development Tools”
3$ pip install isso
如果遇到这样的错误:
1Successfully built pyparsing
2Installing collected packages: pyparsing
3 Found existing installation: pyparsing 2.0.1
4Cannot uninstall 'pyparsing'. It is a distutils installed project and thus we cannot accurately determine
5which files belong to it which would lead to only a partial uninstall.
请执行sudo pip install -I pyparsing==2.2.0
这条命令,然后再次执行pip install isso
安装。
1$ sudo pip install -I pyparsing==2.2.0
查看isso版本
安装后可以查看isso版本,以验证安装成功。
1[root@JoeVPS ~]# isso --version
2isso 0.12.2
如果出现这个错误:
1 from flask_spyne import Spyne, SpyneService, SpyneController
2 File "/usr/local/lib/python2.7/dist-packages/flask_spyne/flask_spyne.py", line 3, in <module>
3
4 from werkzeug.wsgi import DispatcherMiddleware
5ImportError: cannot import name DispatcherMiddleware
说明要么没有安装werkzeug,要么版本太高,解决办法:
1#卸载
2python -m pip uninstall werkzeug
3#安装指定版本
4python -m pip install werkzeug==0.16.0
运行isso
要在服务端运行isso,需要指定配置文件,配置文件可以放在任意位置,任意名字。假设我的配置文件是/usr/local/isso/isso.conf
,运行isso:
1isso -c /usr/local/isso/isso.conf run
初次这样直接运行,肯定会报错,因为目前isso.conf还不存在!下面接着看配置文件怎么设置。
配置文件
1[root@JoeVPS ~]# vim /usr/local/isso/isso.conf
2[general]
3dbpath = /usr/local/isso/comments.db
4host = https://dongzhi.me/
5log-file = /usr/local/isso/log-isso.log
6max-age = 0
7notify = stdout, smtp
8reply-notifications = true
9
10[server]
11listen = http://localhost:8080/
12reload = off
13profile = off
14
15[moderation]
16enabled = true
17purge-after = 30d
18
19[smtp]
20username = my Gmail user name
21password = my Gamil password
22host = smtp.gmail.com
23port = 465
24security = ssl
25to = abc12345@xxx.com
26from = "ISSO Comment System"
27timeout = 10
28
29[guard]
30enabled = true
31ratelimit = 3
32direct-reply = 3
33reply-to-self = true
34require-author = true
35require-email = true
36
37[admin]
38enabled = true
39# 管理员密码
40password = 123456
配置说明:
-
host: 你的网站域名,要以http或https开头,isso会以该字段进行CORS跨域验证
-
listen: 指定isso的端口,以http开头就行,建议值:http://0.0.0.0:port
-
[smtp] 邮件配置。这部分的前5个字段设定的是邮件发送方的smtp配置,
to
字段是接收方邮箱。假设smtp部分填写了Gmail的smtp信息(host,port,username password,security),to设置为你的QQ邮箱,那么当用户评论后,isso将会从后台登录Gmail邮箱,向你的QQ邮箱发送一封邮件! -
[admin] password: 管理员的密码。管理员界面的路径是**
/admin
** -
[general] 中dbpath和log-file分别为数据文件和日志文件路径,目录需要提前创建好。
其他配置可以保持不变,详情参考官网。
配置nginx
用ip访问isso不方便,可以配置成用域名访问,可以是任意域名。假设我的域名是isso.dongzhi.me.
安装nginx和certbot:
1yum install nginx certbot -y
假设域名是isso.dongzhi.me,需要先进行域名的A记录解析,然后使用Let’s Encrypt证书配置nginx:
1certbot --nginx -d isso.dongzhi.me
此时,nginx的配置文件中会多了isso.dongzhi.me相关的虚拟主机配置。
修改nginx配置文件,找到isso.dongzhi.me部分,修改location /
为:
1location / {
2 proxy_pass http://localhost:8080;
3 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
4 proxy_set_header Host $host;
5 proxy_set_header X-Forwarded-Proto $scheme;
6}
重启nginx:
1systemctl restart nginx
此时可以访问admin了。
1curl https://isso.dongzhi.me/admin/
添加服务
添加为服务,使用systemctl来管理isso.
1sudo vim /etc/systemd/system/isso.service
添加一下内容:
1# /etc/systemd/system/isso.service
2[Unit]
3Description=Isso Comment Server
4
5[Service]
6Type=simple
7WorkingDirectory=/usr/local/isso
8ExecStart=/usr/bin/isso -c /usr/local/isso/isso.conf run
9Restart=on-failure
10RestartSec=5
11ExecStop=kill -l SIGQUIT `pgrep isso`
12[Install]
13WantedBy=multi-user.target
注意,本人的isso配置文件路径是/usr/local/isso/isso.conf。
我们使isso服务开启自启动。
1sudo systemctl daemon-reload
2sudo systemctl enable isso
现在,你可以下面的命令来使启动,停止,重启isso服务,也可以查看isso服务的状态:
1sudo systemctl start isso
2sudo systemctl stop isso
3sudo systemctl status isso
4sudo systemctl restart isso
静态网站嵌入
静态网站使用isso非常简单。以Hugo为例。 在页面的底部插入HTML标签:
1<section id="isso-thread" data-title="{{- .Title|default .Site.Title -}}" data-isso-id="{{- .Permalink|absURL -}}"></section>
主要参数说明:
- data-title: 文章标题
- data-isso-id: 文章ID,建议设置成文章的url
然后引入script脚本:
1<script async data-isso-id="thread-id" data-isso="https://isso.dongzhi.me"
2data-isso-css="true"
3data-isso-lang="zh"
4data-isso-reply-notifications="true"
5data-isso-reply-to-self="true"
6data-isso-require-author="true"
7data-isso-require-email="true"
8data-isso-max-comments-top="10"
9data-isso-max-comments-nested="5"
10data-isso-reveal-on-click="5"
11data-isso-avatar="true"
12data-isso-avatar-bg="#f0f0f0"
13data-isso-avatar-fg="#9abf88 #5698c4 #e279a3 #9163b6 ..."
14data-isso-vote="false"
15data-isso-vote-levels=""
16data-isso-feed="false"
17src="https://isso.dongzhi.me/js/embed.min.js"></script>
主要参数说明:
- data-isso: isso服务端的API地址,也就是上面nginx部分配置的域名,注意不要有
/
- src: isso的js地址
- data-isso-css: true表示使用isso的默认样式。如果你觉得isso界面太丑,可以将该字段值设置为false,然后就可以随意修改样式了。
Reference
Installing, configuring, and integrating isso (commenting web app) into Confluence