rhel 7 安装 Rocket.Chat

rhel 7 安装 Rocket.Chat

1安装 epel

1.1centos

yum -y install epel-release nano && yum -y update

1.2rhel

rpm -vih http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-2.noarch.rpm

2安装包

yum install -y nodejs curl GraphicsMagick npm mongodb-org-server mongodb-org gcc-c++

3 mongodb安装

vi /etc/yum.repos.d/mongodb.repo
加入:

  [mongodb]
name=MongoDB Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
gpgcheck=0
enabled=1

3.1 如果有selinux

semanage port -a -t mongod_port_t -p tcp 27017

3.2 创建目录

mkdir -p /home/mongo/{run,log,data}

chown -r mongod:mongod /home/mongo

3.3 mongo加入自定义配置

编辑 /etc/mongo.conf

logpath=/home/mongo/log/mongod.log
dbpath=/home/mongo/data
pidfilepath=/home/mongo/run/mongod.pid
bind_ip=127.0.0.1

3.4自动启动

systemctl enable mongod
systemctl start mongod

4 安装rocket

4.1 npm 降级到 4.5版本

npm install -g inherits n
n 4.5
sudo ln -sf /usr/local/n/versions/node/4.5.0/bin/node /usr/bin/node

4.2 rocket下包安装

cd /home/rocket
curl -L https://rocket.chat/releases/latest/download -o rocket.chat.tgz
tar zxvf rocket.chat.tgz
mv bundle Rocket.Chat
cd Rocket.Chat/programs/server
npm install
## 启动
cd ../..
export PORT=3000
export ROOT_URL=http://your-host-name.com-as-accessed-from-internet:3000/
export MONGO_URL=mongodb://localhost:27017/rocketchat
node main.js

4.3 auto start

vi  /usr/lib/systemd/system/rocketchat.service


[Unit]
Description=The Rocket.Chat server
After=network.target remote-fs.target nss-lookup.target nginx.target mongod.target
[Service]
ExecStart=/usr/local/bin/node /home/rocket/Rocket.Chat/main.js
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=rocketchat
User=root
Environment=MONGO_URL=mongodb://localhost:27017/rocketchat ROOT_URL=http://yourip:3000/ PORT=3000
[Install]
WantedBy=multi-user.target