准备工作

首先,更新系统

apt-get update && apt-get upgrade

更新升级pip

pip install --upgrade pip

开始部署

安装Isso一条命令即可

pip install isso

此时isso已经被完整安装在/usr/local/bin/isso
安装SQLite3
由于Isso用的是SQlite3数据库,我们需要安装

apt-get install sqlite3

新建立一个数据库目录并设置权限

mkdir -p /var/lib/isso

配置Isso
新建立一个conf文件,比如/etc/isso.conf演示内容如下

[general]
dbpath = /var/lib/isso/comments.db
name = example
host = http://example.com/
       http://example.org/
notify = smtp
log-file =

[server]
listen = http://localhost:8090/

[moderation]
enabled = true
purge-after = 30d

[smtp]
username = [email protected]
password = password
host = smtp.example.com
port = 587
security = starttls
to = 你的邮箱地址
from = "Isso Comment"<[email protected]>
timeout = 10

[markup]
options = strikethrough, superscript, autolink
allowed-elements = 
allowed-attributes =

[guard]
enabled = true
ratelimit = 3
direct-reply = 3
reply-to-self = false
require-author = true
require-email = true

[hash]
salt = Eech7co8Ohloopo9Ol6baimi
algorithm = pbkdf2

照官方的配置文件,我们来一条一条说明

[general] 是基本配置,必须填写
dbpath 就是数据库文件,刚才我们已经建立了 /var/lib/isso/ 目录,所以他会自动生成 *必填
name 是这一个配置文件的名字,如果本地只搭建一个 Isso 的话可以忽略,搭建多个 Isso 的话需要设置 *可选
host 是你引用 Isso 的 JS 的网站地址,需要写全,如果有多个的话就多加几行,只有一个域名的话留下一个即可 *必填
notify 评论审核通知方式,如果不开启审核可以不设置,设置了 SMTP 就需要在下面的 [smtp] 设置邮件发送方式 *可选
log-file 记录日志,后续我们会提到,一般不需要开启
[server] 本地服务端设置
listen 需要监听的端口,可以自定义,这里我们用 8090 为例
[moderation] 是否开启评论审核,不需要的话可以写 enabled = false
purge-after 指定多少时间后删除还在审核队列里的评论
[markup] 是 Misaka Markdown 插件
options 可选 strikethrough, superscript, autolink 比如不需要自动加入超链接可以去掉 autolink
allowed-elements 评论开启 HTML 标签,默认允许的标签有 a, blockquote, br, code, del, em, h1, h2, h3, h4, h5, h6, hr, ins, li, ol, p, pre, strong, table, tbody, td, th, thead 和 ul 可以根据自己情况修改
allowed-attributes 评论开启 HTML 标签的属性,默认只允许 align 和 href
[smtp] 审核评论发送邮件通知的设置,具体可以咨询你使用的邮件服务,按服务商提供的配置填写即可,不再详细描述
[guard] 开启评论防火墙,如不需要可以填写 enabled = false
ratelimit 每个访客一分钟最多可以评论的次数
direct-reply 评论回复次数
reply-to-self 是否可以回复自己的评论,需要配合 JS 引用,下面会说
require-author 是否要求写名字,需要配合 JS 引用,下面会说
require-email 是否要求写 Email 地址,需要配合 JS 引用,下面会说
[hash] 加密评论的身份方式,如 Email 地址,没有特殊需求可以忽略

详细的解释可以参考官方的文档,如果没有特殊的需求,也不需要审核评论,直接可以上一份最简单的配置文件,如下

[general]
dbpath = /var/lib/isso/comments.db
host = http://example.com/

[server]
listen = http://localhost:8090/

[moderation]
enabled = false

保存这个文件之后,就可以启动Isso看输出消息是否正常

isso -c /etc/isso.conf run

怎么确定是否已经运行了呢?

curl 127.0.0.1:8090

如果出现:

<title>400 Bad Request</title>
<h1>Bad Request</h1>
<p>missing uri query</p>

那就成功啦 ^_^按ctrl + c停止Isso

最后宝塔反代http://127.0.0.1:8090

在网站引用评论

根据官方文档,直接引用一段 JS 即可,具体参数根据需求自行调整

<script data-isso="http://example.com/isso/" data-isso-css="true" data-isso-lang="en" data-isso-reply-to-self="false" data-isso-require-author="false" data-isso-require-email="false" data-isso-max-comments-top="10" data-isso-max-comments-nested="5" data-isso-reveal-on-click="5" data-isso-avatar="true" data-isso-avatar-bg="#f0f0f0" data-isso-avatar-fg="#9abf88 #5698c4 #e279a3 #9163b6 ..." data-isso-vote="true" data-vote-levels="" src="http://example.com/isso/js/embed.js"></script>
data-isso--Isso安装的 URI
data-isso-css 使用默认的CSS如果需要自己改CSS则设置成false
data-isso-lang默认语言,参考ISO 639-1编码,可选语言列表在这儿
data-isso-reply-to-self,data-isso-require-author,data-isso-require-email 需按照 Isso 配置文件来,请保持一致
data-isso-max-comments-top 一页显示的评论数
data-isso-max-comments-nested 最多嵌套评论数
data-isso-reveal-on-click 超出评论数后点击显示的评论数
data-isso-avatar 显示头像
data-isso-avatar-bg 头像背景
data-isso-avatar-fg 头像颜色
data-isso-vote 开启评论的支持和反对
data-vote-levels 评论支持和反对的等级算法,具体请参考官方的文档

如果没有特殊需求,直接来一行

<script data-isso="http://example.com/isso/" src="http://example.com/isso/js/embed.min.js"></script>

接着在你网站适当的位置加入一个section标签即可

<section id="isso-thread"></section>

如果你网站有多个域名,可以固定当前页面的 URI 和标题,很适合 WordPress 等程序的用户,只有一个域名的忽略即可

<section data-title="当前标题" data-isso-id="当前URI" id="isso-thread"></section>

CSS

#isso-thread {
    padding:8px;
    margin: 8px;
}

#isso-thread .isso-postbox {
    color: #333;
}

#isso-thread .auth-section .input-wrapper {
    margin-right: 4px;
}

#isso-thread .auth-section .post-action input {
    border-style: none;
    padding: 5px 20px;
    color: #DDD;
    background: rgba(255, 255, 255, 0.2);
}

#isso-thread .post-action input:hover {
    color: #FFF;
    background: rgba(255, 255, 255, 0.4);
}

#isso-thread .isso-comment a:hover {
    color: #FFF !important;
}

#isso-thread .isso-comment .isso-comment-header .author {
    color: #DDD;
    font-size: larger;
}

参考1 参考2 参考3

Last modification:September 17, 2019
如果觉得我的文章对你有用,请随意赞赏