说明:Fiora
是一款偏二次元的Web
多人在线聊天应用,使用Node.js
、Mongodb
、Socket.io
和React
编写,使用起来还行,挺简洁的,这里水个搭建教程,有兴趣的可以玩玩。
功能
- 好友,群组,私聊,群聊
- 文本,图片,代码,
url
等多种类型消息 - 贴吧表情,滑稽表情,搜索表情包
- 桌面通知,声音提醒,语音播报
- 自定义桌面背景,主题颜色,文本颜色
- 查看在线用户,
@
功能 - 小黑屋禁言手动安装
Github地址:https://github.com/yinxin630/fiora
所需环境:
Nodejs >= 8.9.0
、Mongodb
。说明:
512M
内存vps
可能还需要先加一点虚拟内存,不然构建过程会失败,可以使用Swap
一键脚本→传送门。1、安装Nodejs
#Debian/Ubuntu系统curl -sL https://deb.nodesource.com/setup_10.x | bash -apt install -y git nodejs #CentOS系统curl -sL https://rpm.nodesource.com/setup_10.x | bash -yum install nodejs git -y
2、安装Mongodb
#CentOS 6系统,将下面命令一起复制进SSH客户端运行cat < /etc/yum.repos.d/mongodb.repo[mongodb-org-4.0]name=MongoDB Repositorybaseurl=https://repo.mongodb.org/yum/redhat/6/mongodb-org/4.0/x86_64/gpgcheck=1enabled=1gpgkey=https://www.mongodb.org/static/pgp/server-4.0.ascEOFyum -y install mongodb-org#CentOS 7系统,将下面命令一起复制进SSH客户端运行cat < /etc/yum.repos.d/mongodb.repo[mongodb-org-4.0]name=MongoDB Repositorybaseurl=https://repo.mongodb.org/yum/redhat/7/mongodb-org/4.0/x86_64/gpgcheck=1enabled=1gpgkey=https://www.mongodb.org/static/pgp/server-4.0.ascEOFyum -y install mongodb-org#Debian 8系统apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4echo "deb http://repo.mongodb.org/apt/debian jessie/mongodb-org/4.0 main" | tee /etc/apt/sources.list.d/mongodb-org-4.0.listapt update -yapt install -y mongodb-org#Debian 9系统curl https://www.mongodb.org/static/pgp/server-4.0.asc | apt-key add -echo "deb http://repo.mongodb.org/apt/debian stretch/mongodb-org/4.0 main" | tee /etc/apt/sources.list.d/mongodb-org-4.0.listapt-get update -yapt-get install -y mongodb-org#Debian 10系统,目前Debian 10还没Mongodb软件包,不过试了下还是可以用下面的方法勉强安装的apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4echo "deb https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.0.listapt update -yapt install -y mongodb-org#Ubuntu 16.04系统apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4echo "deb https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/4.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.0.listapt update -yapt install -y mongodb-org#Ubuntu 18.04、18.10、19.04系统apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4echo "deb https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.0.listapt update -yapt install -y mongodb-org
如果导入公匙时出现
gnupg, gnupg2 and gnupg1 do not seem to be installed
错误,使用apt install -y gnupg2
,然后重新导入即可。启动
Mongodb
并设置开机自启:#CentOS 6系统service mongod startchkconfig mongod on#CentOS 7、Debian、Ubuntu系统systemctl start mongodsystemctl enable mongod
3、安装fiora
#拉取源码并存放于/opt文件夹git clone https://github.com/yinxin630/fiora.git -b master /opt/fioracd /opt/fiora#安装依赖npm i#构建npm run buildmv -f dist/fiora/* public#启动export NODE_ENV=productionnode server/main.js
运行后打开
ip:9200
,注册一个账号,然后可以看SSH
客户端运行日志,获取自己的userId
。#这里注册或登录的时候返回的信息,后面的5d329dd354b9则为自己的userId<-- getLinkmansLastMessages mYNheu93jds7 5d329dd354b9
如果
ip:9200
打不开的,可以检查下防火墙,CentOS
系统可以使用以下命令:#CentOS 6iptables -I INPUT -p tcp --dport 9200 -j ACCEPTservice iptables saveservice iptables restart#CentOS 7firewall-cmd --zone=public --add-port=9200/tcp --permanentfirewall-cmd --reload
像阿里云等,还需要额外在安全组开放端口。
接下来再将自己的账号设置成管理员,先使用
Ctrl+C
断开运行。新建
Systemd
配置文件,只适用于CentOS 7
、Debian 8+
、Ubuntu 16+
等。<code class="hljs cs" courier="" new",="" monospace;="" font-size:="" inherit;="" color:="" black;="" background-color:="" transparent;="" border-radius:="" 0px;="" word-wrap:="" normal;="" display:="" block;="" overflow-x:="" auto;="" position:="" relative;="" margin:="" 10px="" 1px="" 50px;"="" style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: inherit; color: inherit; background-color: transparent; border-radius: 0px; overflow: hidden;">#先修改你的userId和运行端口后复制到SSH运行Administrator=5d329dd354b9Port=9200#新建fiora用户并授权useradd -M fiora && usermod -L fiorachown -R fiora:fiora /opt/fiora#新建systemd配置文件,将以下代码一起复制到SSH运行cat > /etc/systemd/system/fiora.service <<eof [unit]="" description="fiora" after="network.target" wants="network.target" [service]="" type="simple" pidfile="/var/run/fiora.pid" execstart="$(command" -v="" node)="" server="" main.js="" workingdirectory="/opt/fiora" environment="NODE_ENV=production" administrator="$Administrator" port="$Port" user="fiora" restart="on-failure" restartsec="42s" [install]="" wantedby="multi-user.target" eof=""
开始启动并设置开机自启:
systemctl start fiorasystemctl enable fiora
其它系统,比如
CentOS
、Debian 7
等系统,可以直接使用以下方法启动:#管理员userId和运行端口自行修改export NODE_ENV=production Administrator=5d329dd354b9 Port=9200nohup node server/main.js &
此时就可以访问
ip:9200
,运行端口以你设置的为准,这时候你登陆的时候,会发现左侧多了个管理员图标。4、域名反代
如果你想使用域名的话,这里依旧使用Caddy
反代,操作如下:安装
Caddy
:wget -N --no-check-certificate https://raw.githubusercontent.com/ToyoDAdoubiBackup/doubi/master/caddy_install.sh && chmod +x caddy_install.sh && bash caddy_install.sh#备用地址wget -N --no-check-certificate https://www.moerats.com/usr/shell/Caddy/caddy_install.sh && chmod +x caddy_install.sh && bash caddy_install.sh
配置
Caddy
:<pre courier="" new",="" monospace;="" font-size:="" 13px;="" padding
聊天系统
下载地址
https://wwa.lanzoui.com/i53q55e