Cài đặt Rocket.Chat trên Debian 9

Cài đặt Rocket.Chat trên Debian 9

Những thứ cần chuẩn bị:

  • Phiên bản máy chủ VPS Debian 9 mới với ít nhất 1G bộ nhớ. Giả sử địa chỉ IP của nó là 192.167.100.100.
  • Một miền trỏ đến phiên bản máy chủ của bạn. Nói là được www.example.com.

Xem thêm giá cả của VPS: https://inet.vn/vps

1. Cập nhật hệ thống

Đăng nhập với quyền root và cập nhật hệ thống về trạng thái ổn định mới nhất:

apt update
apt upgrade -y
shutdown -r now

2. Cài đặt MongoDB

Cài đặt phiên bản ổn định mới nhất của MongoDB:

apt install mongodb

3. Cài đặt Node.js, GraphicsMagick, npm và các phần bổ trợ khác

Rocket.Chat 0.60 trở lên cần phiên bản 8.9.3 LTS của Node.js để hoạt động. Vì vậy trước đó ta cần  NodeSource Debian:

curl -sL https://deb.nodesource.com/setup_8.x | bash -

Sau đó, chúng ta có thể cài đặt Node.js và các gói khác:

apt install nodejs curl graphicsmagick -y
npm install -g n

Sử dụng nđể cài đặt Node.js phiên bản 8.9.3:

n 8.9.3

4. Cài đặt Rocket.Chat

Tải xuống và cài đặt Rocket.Chat:

cd /opt
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

Để thuận tiện cho bạn, bạn cần tạo đơn vị dịch vụ hệ thống RocketChat:

nano /etc/systemd/system/rocketchat.service

Điền vào tệp. Đảm bảo thay thế miền www.example.combằng miền của bạn:

[Unit]
Description=RocketChat Server
After=network.target remote-fs.target nss-lookup.target mongod.target nginx.target  # Remove or Replace nginx with your proxy

[Service]
ExecStart=/usr/local/bin/node /opt/Rocket.Chat/main.js    # Specify the location of node and location of main.js
Restart=always     # If set to always, the service will be restarted regardless of whether it exited cleanly or not, got terminated abnormally by a signal, or hit a timeout.
RestartSec=10       # Restart service after 10 seconds if node service crashes
StandardOutput=syslog                     # Output to syslog
StandardError=syslog                   # Output to syslog
SyslogIdentifier=nodejs-example
#User=<alternate user>
#Group=<alternate group>
Environment=NODE_ENV=production PORT=3000 ROOT_URL=https://www.example.com MONGO_URL=mongodb://localhost:27017/rocketchat

[Install]
WantedBy=multi-user.target

Lưu ý : Trong PORT, bạn có thể thay thế 3000bằng số cổng bạn chọn. Trong ROOT_URL, bạn có thể thay thế www.example.combằng địa chỉ IP của máy chủ 192.168.100.100, nếu tên miền của bạn không khả dụng.

Bắt đầu dịch vụ MongoDB:

systemctl start mongodb

Khởi động dịch vụ Rocket.Chat:

systemctl start rocketchat

5. Truy cập Rocket.Chat trong trình duyệt web

Trỏ trình duyệt web của bạn đến http://www.example.com:3000.

 

Be the first to comment

Leave a Reply

Your email address will not be published.


*