How to Create Your Own Chat System with Rocket Chat on ECS

By Alex Mungai Muchiri, Alibaba Cloud Tech Share Author. Tech Share is Alibaba Cloud’s incentive program to encourage the sharing of technical knowledge and best practices within the cloud community.

We all love open source because it is both free and resourceful. Without doubt all aspects of ICT applications would be without the power of open source software! In this tutorial, we shall be deploying a chat system that can serve both companies and communities or groups that want to have their own internal chat servers. This makes a lot of sense because of the added privacy for trade secrets and another sort of information that you may not want to share with third parties. Rocket Chat is such a system, which allows you to do what Slack can, but in your own server. You can collaborate with coworkers, share files, make calls, respond to queries and even leave voice notes to members. In this tutorial, we shall be looking at how we could install Rocket Chat in an ECS instance that is running Ubuntu OS. As we shall see below, there are two ways to approach this installation but we shall lay emphasis on the second one as it is more detailed.

What You Need for This Tutorial

You will need the following to follow through the tutorial:

  • Your ECS instance that is running on updated Ubuntu OS i.e. 16.04 or 18.04 (although lower versions have been used before).
  • The ideal VPS should be configured with 2GB RAM, 10GB of space and either 2 or 4 cores. Nonetheless, it is still possible to install Rocket Chat in a 1GB RAM, 10GB of space and 1 core.
  • You should also have your domain registered with a registrar and point it to your server’s IP address
  • Install and configure Nginx web server in your VPS
  • If you need to, set up an SSL certificate for your domain

With that done, now you are ready to deploy Rocket Chat in your ECS instance. There are two methods that you can follow. Rocket chat offers exclusive support for Aliyun services, the same service that supports Alibaba Cloud. The first method entails the use of ‘Snaps’ for your installation.

1.0 Snaps Installation

Snap installation for Ubuntu systems is really easy with Rocket Chat. Initiate the process by running the command below:

For additional configurations, you will then access the address below to access Rocket Chat setups:

If by any chance you are running an Ubuntu 14.04 server, there is a small additional step that you need to start with: installing snapd using the command below:

In case you are wondering why you would use the Snaps method for installation, it is because it is fast and easy to install. Furthermore, that method of installation will isolate the Rocket Chat files and dependencies so that they do not interfere with other system processes in your ECS instance. There is also no need for running updates since Snaps update themselves automatically. Alright, we shall not dwell much on Snaps installation as it is rather straight forward.

What You Need to Know About Snaps Installation

A substantial percentage of Rocket Chat installations are Snaps-based. As we mentioned above, you need not worry about making updates with new releases when working with Snaps since they auto update. Noteworthy, however, is that updates take about two weeks to a month more after a new release and you may have to consider other installation methods if you want to update as soon as a new release is available. Due to this lag in updates release, some users opt for Docker installation method or the method that we shall discuss below.

Troubleshoot Snaps Installation

One of the commonly encountered problems with Snaps installation is ‘snap not found’ error. Well, you must be running an x64 or amd64 ECS instance or virtual machine. Other systems are not supported by Snaps.

If you need to run updates manually, run the command below, but this may not be necessary since updates run automatically about 6 hours after being made available

Additionally, you can roll back updates if you want by running the command below:

Do you want to know if your chat system is running as expected? Run a system check through the command below:

The commands below check for the status of Rocket Chat dependencies Mongo and Caddy:

Run the command below to see the Rocket Chat client logs

For Mongo or Caddy logs, you will need to run the commands below:

The final aspect about troubleshooting is restarting Rocket Chat if you need to. Usually, it will automatically restart upon failure but you may still need to restart. By the way, you can also restart Caddy and Mongo as well.

Restart Rocket Chat like so:

Run the commands below to restart Mongo and Caddy:

That’s it for Snaps installation, we shall be making more configurations in the second type of installation discussed in this tutorial.

2.0 Manual Installation

In this section, we shall install Rocket Chat manually, whereby we shall begin by installing its dependencies.

Install Dependencies

Run the command below to run a system update:

The next step is to install Node.js and npm by running the command below:

Now run the command below to install n, which is a npm package for interactive management of Node.js:

Next, we shall install MongoDB, which Rocket Chat uses to store data. First, we need to import the key required by apt for installation of official MongoDB packages by running the command below:

Next, run the command below:

Next, run the update below to install Mongo:

Enable Mongo service like so:

Install Rocket Chat

To begin with, let us create a new sudo user for our Rocket Chat service like so:

Run the command below to add the user www-data to the group you just created:

Finally, update the /opt/rocket directory permissions to allow Nginx access. Now we are all set for the next step.

Now switch to our rocket user like so:

Now download Rocket Chat by running the command below:

Next, run the extraction command below to extract downloaded files:

Next, change to the Rocket.Chat directory that was created when extracting files above:

Next, run the command below to configure environment variables for our installation:

Now change back to Rocket.Chat directory and run the command below to start the service

You should see an output as the one below:

Now that our Rocket Chat server is running, press CTRL+C to stop it and then exit to the sudo user. In the next step, we shall configure Rocket Chat as a system service using Systemd.

Create a Rocket Chat System Service

In this step, we need to access /etc/systemd/system/ directory and create a rocketchat.service file in it. The easiest way to do this is to use WinSCP or use the command line as we have done so far. I prefer using WinSCP for this step:

So, our preferred domain in the file has been set to rocket.rockchatty.com, which should now be pointed to your ECS IP address.

Now run the command below to initiate the service through Systemd:

confirm that the changes have taken place by running the command below:

You should get the usual information with the PID, CGroup and Active status if the installation completed successfully.

Now run the command below to run Rocket Chat at system start-up:

For us to be able to access the service by typing a URL, we shall need to configure Nginx. In the next step, we configure a reverse proxy with Nginx

Configuring Nginx

Access your folders in WinSCP and navigate to /etc/nginx/sites-available and create a new file named rocket.rockchatty.com.config. Now, in your editor, open it and make the following addition to it:

Now, navigate to /etc/nginx/sites-enabled and create a new file named rocket.rockchatty.com.config. Copy the contents of our configuration file above to the new file.

Once that is done, run the command below:

Final Configurations

In this step, we shall make the final configurations on Rocket Chat, which should already be accessible via a browser by typing in your configured URL

Once accessed, the setup wizard should be easy to follow in setting up admin user and getting your server registered for push notifications. Below is the page that you should see, just follow along and fill all required information as prompted:

Conclusion

That is it for today. We have set up Rocket Chat in our ECS instance running Ubuntu and configured Nginx reverse proxy. Visit https://rocket.chat/docs/ for further information. Don’t have an Alibaba Cloud account yet? Sign up for an account and try over 40 products for free worth up to $1200.

Original Source

https://www.alibabacloud.com/blog/how-to-create-your-own-chat-system-with-rocket-chat-on-ecs_594975?spm=a2c41.13103125.0.0

Follow me to keep abreast with the latest technology news, industry insights, and developer trends.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store