【2.5】评论系统--hashover

一、安装步骤(centos7)

1.1 修改运行php的用户

(如果不存在用户读写权限问题,这一步可以不做)

vi /etc/php-fpm.d/www.conf

user = apache
group = apache

改为

user = sam
group = sam

然后重启php-frp服务

systemctl restart php-fpm.service

因为我的网址的用户是sam,而php-fpm默认的用户为apache,这样没办法在我的网站文件夹下读写文件

1.2 下载配置

下载

cd /home/sam/blog
git clone https://github.com/jacobwb/hashover-next.git
cp -fr hashover-next/hashover/ ./public/hashover

修改secrets.php配置

vim hashover/backend/classes/secrets.php

修改如下几项:

protected $notificationEmail = '**@sina.cn';

    // Unique encryption key (case-sensitive)
    protected $encryptionKey = '8CharKey123';

    // Login name to gain admin rights (case-sensitive)
    protected $adminName = '****';   #用于后面登陆的账号

    // Login password to gain admin rights (case-sensitive)
    protected $adminPassword = '*******';  ## 账号密码


    邮件部分
    // OPTIONAL SMTP MAILER SETUP

    // SMTP server host name
    protected $smtpHost = 'smtp.163.com';

    // SMTP server port number
    protected $smtpPort = 465;

    // SMTP server encryption method
    protected $smtpCrypto = 'ssl';

    // SMTP server requires login authentication
    protected $smtpAuth = true;

    // SMTP server user
    protected $smtpUser = '邮件用户名;

    // SMTP server password
    protected $smtpPassword = '****邮件密码';

修改sensitivesettings

vim hashover/backend/classes/sensitivesettings.php

一个是图片后缀,一个是域名管理,其中域名必填否则连不上,本地测试用就填"localhost"

// Types of images allowed to be embedded in comments
public $imageTypes = array (
'jpeg',
'jpg',
'png',
'gif'
);
// External domains allowed to remotely load HashOver scripts
public $allowedDomains = array (
 'qinqianshan.com'
// '*.example.com',
// '*.example.org',
// '*.example.net'
);

之后访问“域名/hashover/admin/”按照之前填写的信息登录就可以管理了,后台有中文 功能也不多无需多言,使用就是在需要嵌入评论的位置加上

配置

‘America/Los_Angeles’ => ‘Asia/Shanghai’;

1.3显示评论

在你的前端模版内容加入

<script type="text/javascript" src="/hashover/loader.php"></script> 

在评论位置加入

<div id="hashover">
	<center id="loading"> 
		<img src="./hashover/images/loading-ltr.gif" alt="Loading..." width="90" height="30">
	</center>
</div>

说明:

<center id="loading"> </code>这部分是加载提示,你可以直接删除,或者自己制作一个gif 替换。
但是   <div id="hashover"> </div> 必须有

<script type="text/javascript">
$("#hashover-sort-select").val("threaded-by-date").change(); //#这句就是模拟点击排序为新评论优先显示而已。
$("#hashover-end-links").remove();  //#这句厉害了,这句是删除下面的链接信息!
</script>

1.4 优化配置

参考资料

药企,独角兽,苏州。团队长期招人,感兴趣的都可以发邮件聊聊:tiehan@sina.cn
个人公众号,比较懒,很少更新,可以在上面提问题,如果回复不及时,可发邮件给我: tiehan@sina.cn