Riot:开源的IM聊天系统

热门标签

日主题主题

简洁、安全、稳定、响应式布局多功能模板。

¥10 现在购买

特别声明:文章多为网络转载,资源使用一般不提供任何帮助,特殊资源除外,如有侵权请联系!

<p> 其实在开源聊天系统这块,我个人目前只推荐RocketChat。因为这套系统是目前使用最方便,并且功能最丰富的。有关部署的教程可以浏览:</p><p><iframe class="wp-embedded-content" title="《使用RocketChat搭建一个属于自己的IM聊天系统》—荒岛" src="https://lala.im/2705.html/embed#?secret=SPVruHuGjz" width="500" height="306" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" sandbox="allow-scripts" data-secret="SPVruHuGjz" data-mce-fragment="1"></iframe></p><p>Riot和RocketChat最大的区别就在于,Riot提供免费的公共聊天服务器,而RocketChat只提供收费服务器托管(有免费试用)。</p><p>Riot和RocketChat一样,都可以自行部署服务器端。也就是说如果你不想用官方给你提供的现成服务器,那么你可以自己部署服务器端在任何一台VPS上。</p><p>如果你不自行部署Riot的服务器端,那么可以说Riot是开箱即用的。我们作为用户而言,目前有三种可以使用Riot的方案:</p><p>1、直接访问https://riot.im/app/#/register注册一个账号,登录即可开始聊天。</p><p>2、仅部署前端的WEB端。目的是可以自己DIY一下登录界面什么的,但依旧使用riot.im的公共服务器。</p><p>3、部署WEB端的同时还部署服务器端。最麻烦,但所有的资源都是独享的。</p><p>我个人建议部署一个WEB端就行了,自建的服务器不好管理,数据备份也是个问题。当然,毕竟折腾就在于享受过程,我这篇文章会把部署服务器端的过程详细写一遍。</p><p>系统使用CentOS7X64</p><p>首先安装开发工具包:</p><pre class="prettyprint"><span class="pln">yum </span><span class="pun">-</span><span class="pln">y groupinstall </span><span class="str">"Development Tools"</span></pre><p>安装程序所需依赖:</p><pre class="prettyprint"><span class="pln">yum </span><span class="pun">-</span><span class="pln">y install libtiff</span><span class="pun">-</span><span class="pln">devel libjpeg</span><span class="pun">-</span><span class="pln">devel libzip</span><span class="pun">-</span><span class="pln">devel freetype</span><span class="pun">-</span><span class="pln">devel lcms2</span><span class="pun">-</span><span class="pln">devel libwebp</span><span class="pun">-</span><span class="pln">devel tcl</span><span class="pun">-</span><span class="pln">devel tk</span><span class="pun">-</span><span class="pln">devel redhat</span><span class="pun">-</span><span class="pln">rpm</span><span class="pun">-</span><span class="pln">config python</span><span class="pun">-</span><span class="pln">virtualenv libffi</span><span class="pun">-</span><span class="pln">devel openssl</span><span class="pun">-</span><span class="pln">devel</span></pre><p>安装pip:</p><pre class="prettyprint"><span class="pln">easy_install pip</span></pre><p>创建虚拟运行环境:</p><pre class="prettyprint"><span class="pln">virtualenv </span><span class="pun">~/.</span><span class="pln">synapse</span></pre><p>激活运行环境:</p><pre class="prettyprint"><span class="pln">source </span><span class="pun">~</span><span class="str">/.synapse/</span><span class="pln">bin</span><span class="pun">/</span><span class="pln">activate</span></pre><p>升级pip到最新版本:</p><pre class="prettyprint"><span class="pln">pip install </span><span class="pun">--</span><span class="pln">upgrade pip</span></pre><p>升级setuptools:</p><pre class="prettyprint"><span class="pln">pip install </span><span class="pun">--</span><span class="pln">upgrade setuptools</span></pre><p>使用pip安装Matrix:</p><pre class="prettyprint"><span class="pln">pip install https</span><span class="pun">:</span><span class="com">//github.com/matrix-org/synapse/tarball/master</span></pre><p>确认安装成功是类似如下图的回显,如果有错误就要根据自己的错误信息来排查解决了:</p><p><img class="img-thumbnail" src="https://lala.im/wp-content/uploads/2018/05/lala.im_2018-05-15-45-849.png" alt="Riot:开源的IM聊天系统" caption="Riot:开源的IM聊天系统" title="Riot:开源的IM聊天系统"/></p><p>现在进入到程序目录</p><pre class="prettyprint"><span class="pln">cd </span><span class="pun">~/.</span><span class="pln">synapse</span></pre><p>执行如下命令创建一个配置文件:</p><pre class="prettyprint"><span class="pln">python </span><span class="pun">-</span><span class="pln">m synapse</span><span class="pun">.</span><span class="pln">app</span><span class="pun">.</span><span class="pln">homeserver </span><span class="pun">--</span><span class="pln">server</span><span class="pun">-</span><span class="pln">name biubiubiu </span><span class="pun">--</span><span class="pln">config</span><span class="pun">-</span><span class="pln">path homeserver</span><span class="pun">.</span><span class="pln">yaml </span><span class="pun">--</span><span class="pln">generate</span><span class="pun">-</span><span class="pln">config </span><span class="pun">--</span><span class="pln">report</span><span class="pun">-</span><span class="pln">stats </span><span class="kwd">no</span></pre><p>注:–server-name这里最好填写一个你的站点域名,如果是测试的话,填写你的系统主机名即可。</p><p>运行Matrix:</p><pre class="prettyprint"><span class="pln">synctl start</span></pre><p>因为是初次运行,我们需要创建一个管理员账号,执行:</p><pre class="prettyprint"><span class="pln">register_new_matrix_user </span><span class="pun">-</span><span class="pln">c homeserver</span><span class="pun">.</span><span class="pln">yaml http</span><span class="pun">:</span><span class="com">//localhost:8008</span></pre><p>如图所示:</p><p><img class="img-thumbnail" src="https://lala.im/wp-content/uploads/2018/05/lala.im_2018-05-15-21-525.png" alt="Riot:开源的IM聊天系统" caption="Riot:开源的IM聊天系统" title="Riot:开源的IM聊天系统"/></p><p>编辑homeserver.yaml</p><pre class="prettyprint"><span class="pln">vi homeserver</span><span class="pun">.</span><span class="pln">yaml</span></pre><p>开启用户注册:</p><pre class="prettyprint"><span class="pln">enable_registration</span><span class="pun">:</span> <span class="kwd">True</span></pre><p>如图所示:</p><p><img class="img-thumbnail" src="https://lala.im/wp-content/uploads/2018/05/lala.im_2018-05-15-21-400.png" alt="Riot:开源的IM聊天系统" caption="Riot:开源的IM聊天系统" title="Riot:开源的IM聊天系统"/></p><p>然后重启Matrix:</p><pre class="prettyprint"><span class="pln">synctl restart</span></pre><p>现在服务已经成功跑在机器的本地了,要对外网提供访问,必然要配置一个反向代理。这里我使用Nginx。</p><p>新建一个repo:</p><pre class="prettyprint"><span class="pln">vi </span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">yum</span><span class="pun">.</span><span class="pln">repos</span><span class="pun">.</span><span class="pln">d</span><span class="pun">/</span><span class="pln">nginx</span><span class="pun">.</span><span class="pln">repo</span></pre><p>写入:</p><pre class="prettyprint"><span class="pun">[</span><span class="pln">nginx</span><span class="pun">]</span><span class="pln">name</span><span class="pun">=</span><span class="pln">nginx repobaseurl</span><span class="pun">=</span><span class="pln">http</span><span class="pun">:</span><span class="com">//nginx.org/packages/centos/7/$basearch/</span><span class="pln">gpgcheck</span><span class="pun">=</span><span class="lit">0</span><span class="pln">enabled</span><span class="pun">=</span><span class="lit">1</span></pre><p>执行:</p><pre class="prettyprint"><span class="pln">yum </span><span class="pun">-</span><span class="pln">y install nginx</span></pre><p>设置Nginx开机启动并运行Nginx:</p><pre class="prettyprint"><span class="pln">systemctl enable nginxsystemctl start nginx</span></pre><p>新建一个站点conf:</p><pre class="prettyprint"><span class="pln">vi </span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">nginx</span><span class="pun">/</span><span class="pln">conf</span><span class="pun">.</span><span class="pln">d</span><span class="pun">/</span><span class="pln">riot</span><span class="pun">.</span><span class="pln">conf</span></pre><p>写入:</p><pre class="prettyprint"><span class="pln">server </span><span class="pun">{</span><span class="pln"> listen </span><span class="lit">80</span><span class="pun">;</span><span class="pln"> server_name </span><span class="pun">你的站点域名;</span><span class="pln"> location </span><span class="pun">/</span> <span class="pun">{</span><span class="pln"> proxy_pass http</span><span class="pun">:</span><span class="com">//localhost:8008;</span><span class="pln"> proxy_set_header </span><span class="typ">Host</span><span class="pln"> $host</span><span class="pun">;</span><span class="pln"> proxy_set_header X</span><span class="pun">-</span><span class="typ">Real</span><span class="pun">-</span><span class="pln">IP $remote_addr</span><span class="pun">;</span> <span class="pun">}</span><span class="pun">}</span></pre><p>重启Nginx:</p><pre class="prettyprint"><span class="pln">systemctl restart nginx</span></pre><p>这样,我们就部署好了一台Riot的聊天服务器。其实现在已经有一个简陋的WEBUI可以提供最基础的聊天功能了,此时,你访问你的网站域名可以看到如下图的页面。但这个WEBUI太简陋了,很显然不适合让用户去使用:</p><p><img class="img-thumbnail" src="https://lala.im/wp-content/uploads/2018/05/lala.im_2018-05-17-13-326.png" alt="Riot:开源的IM聊天系统" caption="Riot:开源的IM聊天系统" title="Riot:开源的IM聊天系统"/></p><p>所以Riot为Matrix专门开发了一套全新的WEBUI。现在,我们就来部署这个全新的WEB端。(不部署后端服务器,就直接看这里)</p><p>下载WEB端源码:</p><pre class="prettyprint"><span class="pln">wget https</span><span class="pun">:</span><span class="com">//github.com/vector-im/riot-web/releases/download/v0.15.0-rc.4/riot-v0.15.0-rc.4.tar.gz -O /usr/share/nginx/riot-v0.15.0-rc.4.tar.gz</span></pre><p>进入到Nginx的站点目录内:</p><pre class="prettyprint"><span class="pln">cd </span><span class="pun">/</span><span class="pln">usr</span><span class="pun">/</span><span class="pln">share</span><span class="pun">/</span><span class="pln">nginx</span><span class="pun">/</span></pre><p>解压压缩包:</p><pre class="prettyprint"><span class="pln">tar </span><span class="pun">-</span><span class="pln">xzvf riot</span><span class="pun">-</span><span class="pln">v0</span><span class="pun">.</span><span class="lit">15.0</span><span class="pun">-</span><span class="pln">rc</span><span class="pun">.</span><span class="lit">4.tar</span><span class="pun">.</span><span class="pln">gz</span></pre><p>重命名目录:</p><pre class="prettyprint"><span class="pln">mv riot</span><span class="pun">-</span><span class="pln">v0</span><span class="pun">.</span><span class="lit">15.0</span><span class="pun">-</span><span class="pln">rc</span><span class="pun">.</span><span class="lit">4</span><span class="pln"> riot</span></pre><p>将目录的所有者改为nginx:</p><pre class="prettyprint"><span class="pln">chown </span><span class="pun">-</span><span class="pln">R nginx</span><span class="pun">:</span><span class="pln">nginx riot</span></pre><p>新建一个站点conf:</p><pre class="prettyprint"><span class="pln">vi </span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">nginx</span><span class="pun">/</span><span class="pln">conf</span><span class="pun">.</span><span class="pln">d</span><span class="pun">/</span><span class="pln">riot</span><span class="pun">-</span><span class="pln">web</span><span class="pun">.</span><span class="pln">conf</span></pre><p>写入:</p><pre class="prettyprint"><span class="pln">server </span><span class="pun">{</span><span class="pln"> listen </span><span class="lit">80</span><span class="pun">;</span><span class="pln"> server_name </span><span class="pun">你的站点域名;</span> <span class="com">#charset koi8-r;</span> <span class="com">#access_log /var/log/nginx/host.access.log main;</span><span class="pln"> location </span><span class="pun">/</span> <span class="pun">{</span><span class="pln"> root </span><span class="pun">/</span><span class="pln">usr</span><span class="pun">/</span><span class="pln">share</span><span class="pun">/</span><span class="pln">nginx</span><span class="pun">/</span><span class="pln">riot</span><span class="pun">;</span><span class="pln"> index index</span><span class="pun">.</span><span class="pln">html index</span><span class="pun">.</span><span class="pln">htm</span><span class="pun">;</span> <span class="pun">}</span><span class="pun">}</span></pre><p>重启Nginx:</p><pre class="prettyprint"><span class="pln">systemctl restart nginx</span></pre><p>关闭防火墙:</p><pre class="prettyprint"><span class="pln">systemctl stop firewalld</span><span class="pun">.</span><span class="pln">service</span></pre><p>这样,我们就完成了WEB端和服务器端的部署。下面简要说一下使用方法。</p><p>首先,这个全新的WEBUI长这样,是不是比之前的那个要好看多了:</p><p><img class="img-thumbnail" src="https://lala.im/wp-content/uploads/2018/05/lala.im_2018-05-17-32-866.png" alt="Riot:开源的IM聊天系统" caption="Riot:开源的IM聊天系统" title="Riot:开源的IM聊天系统"/></p><p>点击左上角的注册按钮可以注册新账号,但注册的时候要选择我们自建的服务器地址,如下图红框标注的地方,就是你们要更改的:</p><p><img class="img-thumbnail" src="https://lala.im/wp-content/uploads/2018/05/lala.im_2018-05-17-24-145.png" alt="Riot:开源的IM聊天系统" caption="Riot:开源的IM聊天系统" title="Riot:开源的IM聊天系统"/></p><p>同理,登录的时候也是要这样选择的。另外值得一提的是,这个WEBUI支持多国语言,包括中文在内,在登录页面可以自行选择:</p><p><img class="img-thumbnail" src="https://lala.im/wp-content/uploads/2018/05/lala.im_2018-05-17-15-963.png" alt="Riot:开源的IM聊天系统" caption="Riot:开源的IM聊天系统" title="Riot:开源的IM聊天系统"/></p><p>我们测试一下是否能够正常进行聊天:</p><p><img class="img-thumbnail" src="https://lala.im/wp-content/uploads/2018/05/lala.im_2018-05-17-33-920.png" alt="Riot:开源的IM聊天系统" caption="Riot:开源的IM聊天系统" title="Riot:开源的IM聊天系统"/></p><p>OK,完全正常。那么这套聊天程序就可以说是部署完成了~</p><p>写在最后:</p><p>关于这套系统的升级,可参考:https://github.com/matrix-org/synapse/blob/master/UPGRADE.rst</p><p>其他系统的安装方法,可参考:https://github.com/matrix-org/synapse#platform-specific-instructions</p><p>反正我个人不推荐自建这套系统的服务器端,原因有三:</p><p>1、管理数据、备份数据麻烦,程序感觉写的乱七八糟的,依赖这个又依赖那个,不太适合生产环境。</p><p>2、这套程序在账号权限控制这方面做的很不好,比如说管理员账号,连一个后台管理的界面都没有。更别提能管理其他的用户了。</p><p>3、作为一款聊天程序,搜索功能未免太过于鸡肋,搜索用户只能通过搜索这个用户的邮箱才能搜索到,但邮箱并不是注册时的必填项,也就是说如果这个用户没有填写邮箱,那么你无法搜索到这个用户,搜都搜不到还怎么聊天啊。。。我也是醉的一匹。 </p>
本文最后更新于2018年7月17日,已超过 1 年没有更新,如果文章内容或图片资源失效,请留言反馈,我们会及时处理,谢谢!
标签:

未经允许不得转载:作者:yxy021598, 转载或复制请以 超链接形式 并注明出处 红柳客
原文地址:《Riot:开源的IM聊天系统》 发布于2018-07-17

分享到:
赞(0) 打赏

评论 抢沙发

1 + 3 =


Riot:开源的IM聊天系统

长按图片转发给朋友

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏

Vieu4.0主题
专业打造轻量级个人企业风格博客主题!专注于前端开发,全站响应式布局自适应模板。
切换注册

登录

忘记密码 ?

您也可以使用第三方帐号快捷登录

Q Q 登 录
微 博 登 录
切换登录

注册