Launching Rocket.Chat on CentOS 7
In the galactic expanse of communication platforms, Rocket.Chat emerges as a shining star, offering a versatile and customizable solution for seamless interaction. The journey to deploy Rocket.Chat on CentOS 7 is akin to preparing a spacecraft for a cosmic voyage—meticulous, precise, and filled with anticipation. Let’s embark on this odyssey, navigating the celestial landscape of setting up Rocket.Chat on your CentOS 7 server, exploring the steps with finesse and clarity.
Preparing Your CentOS 7 Environment
Before igniting the engines of Rocket.Chat, fortifying the CentOS 7 environment lays the foundation for a successful launch. Begin by ensuring your server is up-to-date with the latest patches and packages. Utilize the command-line prowess of yum, the package manager, to update the system:
sudo yum update
Next, fortify your system’s security by enabling and configuring the firewall to allow essential ports for Rocket.Chat, such as 80 (HTTP) and 443 (HTTPS). The firewalld utility becomes your ally in this endeavor:
sudo firewall-cmd --zone=public --add-port=80/tcp --permanent
sudo firewall-cmd --zone=public --add-port=443/tcp --permanent
sudo firewall-cmd --reload
Setting Up MongoDB
MongoDB serves as Rocket.Chat’s celestial database, storing the constellations of conversations and user data. Prepare the cosmic ground by installing MongoDB, the celestial vault for Rocket.Chat’s data. Begin by adding the MongoDB repository:
sudo vi /etc/yum.repos.d/mongodb-org-4.4.repo
Now, populate the repository with the MongoDB configuration for CentOS 7:
[mongodb-org-4.4]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.4/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.4.asc
After configuring the repository, install MongoDB:
sudo yum install -y mongodb-org
Finally, start and enable the MongoDB service:
sudo systemctl start mongod
sudo systemctl enable mongod
Installing Node.js and npm
Rocket.Chat cruises through the digital cosmos with the aid of Node.js and npm, essential components for its operations. To install Node.js on CentOS 7, first, you’ll need to set up the Node.js repository:
sudo yum install -y gcc-c++ make
sudo curl -sL https://rpm.nodesource.com/setup_14.x | sudo bash -
Once the repository is set up, install Node.js and npm:
sudo yum install -y nodejs
Verify the Node.js and npm installations by checking their versions:
node -v
npm -v
Deploying Rocket.Chat
The stage is set, the groundwork complete—time to unleash Rocket.Chat into your CentOS 7 environment. Begin by downloading the latest release from the official Rocket.Chat repository on GitHub:
curl -L https://releases.rocket.chat/latest/download -o rocket.chat.tgz
Unpack the downloaded file:
tar -xzf rocket.chat.tgz
Move Rocket.Chat to its designated home directory:
mv bundle Rocket.Chat
Enter the Rocket.Chat directory and install its dependencies:
cd Rocket.Chat/programs/server
npm install
Finally, lift off Rocket.Chat by starting the server:
cd ..
node main.js
Configuring Nginx as a Reverse Proxy
To make Rocket.Chat accessible to the cosmic inhabitants of the internet, configure Nginx as a reverse proxy. Begin by installing Nginx on CentOS 7:
sudo yum install -y nginx
Craft an Nginx configuration file for Rocket.Chat:
sudo vi /etc/nginx/conf.d/rocketchat.conf
Populate the file with the following configuration:
server {
listen 80;
server_name your_domain.com;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forward-Proto http;
proxy_set_header X-Nginx-Proxy true;
proxy_redirect off;
}
}
After saving the configuration, restart Nginx:
sudo systemctl restart nginx