<\/span><\/h2>\nRocket.Chat requires a MongoDB database server, version 3.2 or higher. At the moment of writing this article, the latest MongoDB version available in the official Ubuntu 18.04 repository is 3.6.3. While this server version will work fine, it’s always ideal to use the latest version possible. In order to install a more recent version of MongoDB, we will install the database server from the MongoDB repositories. These repositories can be easily added by importing the MongoDB public key with the following command:<\/p>\n
apt-key adv --keyserver hkp:\/\/keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4<\/pre>\nOutput:<\/p>\n
Executing: \/tmp\/apt-key-gpghome.LTAnWbMyRv\/gpg.1.sh --keyserver hkp:\/\/keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4\r\ngpg: key 68818C72E52529D4: public key \"MongoDB 4.0 Release Signing Key <packaging@mongodb.com>\" imported\r\ngpg: Total number processed: 1\r\ngpg: imported: 1<\/pre>\nThen add the repository and install the MongoDB database server along with a few of its dependencies:<\/p>\n
echo \"deb https:\/\/repo.mongodb.org\/apt\/ubuntu bionic\/mongodb-org\/4.0 multiverse\" | sudo tee \/etc\/apt\/sources.list.d\/mongodb-org-4.0.list\r\napt update && apt install -y mongodb-org curl graphicsmagick<\/pre>\nWith this step, MongoDB is now installed and ready to use. We can check the version using the following command:<\/p>\n
mongod -version\r\nversion v4.0.6<\/pre>\nBut in order to start it as a service, a systemd unit file is required. Create a file in \/etc\/systemd\/system\/ using your preferred text editor – we’ll be using ‘nano’. We can create it with the following command:<\/p>\n
nano \/etc\/systemd\/system\/mongodb.service<\/pre>\nNow add these contents to the file:<\/p>\n
[Unit]\r\nDescription=High-performance, schema-free document-oriented database server\r\nAfter=network.target\r\n\r\n[Service]\r\nUser=mongodb\r\nExecStart=\/usr\/bin\/mongod --quiet --config \/etc\/mongod.conf\r\n\r\n[Install]\r\nWantedBy=multi-user.target\r\n<\/pre>\nWhen finished, save and exit the file. Then reload the units using systemctl:<\/p>\n
systemctl daemon-reload<\/pre>\nNow we can check if MongoDB is up and running. That can be done using this command:<\/p>\n
systemctl status mongodb<\/pre>\nThe output should look like this:<\/p>\n
mongodb.service - High-performance, schema-free document-oriented database\r\n Loaded: loaded (\/etc\/systemd\/system\/mongodb.service; disabled; vendor preset: enabled)\r\n Active: active (running) since Fri 2019-03-15 03:42:11 CDT; 59min ago\r\n Main PID: 30802 (mongod)\r\n Tasks: 27 (limit: 2320)\r\n CGroup: \/system.slice\/mongodb.service\r\n 30802 \/usr\/bin\/mongod --quiet --config \/etc\/mongod.conf<\/pre>\nNext, start the MongoDB server and enable it to automatically start after a reboot.<\/p>\n
systemctl start mongodb\r\nsystemctl enable mongodb<\/pre>\n<\/span>Step 3: Install Node.js<\/strong><\/span><\/h2>\nRocket.Chat requires Node.js. It can be easily installed from the official Ubuntu repositories:<\/p>\n
apt -y install node.js<\/pre>\nOnce installed, check the installed version:<\/p>\n
node --version\r\nv8.10.0<\/pre>\nNext, install the ‘npm’ package manager (along with some other dependencies required for building npm packages from source):<\/p>\n
apt install npm build-essential<\/pre>\nAccording to Rocket.Chat’s official documentation it is recommended to have version 8.11.3 of Node.js. The version can be easily changed using a tool named ‘n’:<\/p>\n
npm install -g inherits n && n 8.11.3<\/pre>\nOutput:<\/p>\n
install : node-v8.11.3\r\n mkdir : \/usr\/local\/n\/versions\/node\/8.11.3\r\n fetch : https:\/\/nodejs.org\/dist\/v8.11.3\/node-v8.11.3-linux-x64.tar.gz\r\n installed : v8.11.3\r\n<\/pre>\nYou can verify that the desired version of Node.js is installed:<\/p>\n
node --version\r\nv8.11.3<\/pre>\n<\/span>Step 4: Install Rocket.Chat<\/strong><\/span><\/h2>\nIt is not recommended to run Rocket.Chat as user root, so the next step will be to create a new system user.<\/p>\n
useradd -m -U -r -d \/opt\/rocketchat rocketchat<\/pre>\nSwitch the user to the newly created one:<\/p>\n
su - rocketchat<\/pre>\nThen download the latest stable release of Rocket.Chat in a directory on your server. Make sure to change to that directory first. Here’s the command for downloading the latest version of Rocket.Chat:<\/p>\n
curl -L https:\/\/releases.rocket.chat\/latest\/download -o rocket.chat.tgz<\/pre>\nOnce it is downloaded, unpack the Rocket.Chat archive:<\/p>\n
tar zxvf rocket.chat.tgz<\/pre>\nThe contents of the application will be stored in a new directory named \u2018bundle\u2019. We will rename the directory to ‘rocketchat’:<\/p>\n
mv bundle rocketchat<\/pre>\nChange the current working directory and use the npm package manager to install all dependencies listed in the packages.json file provided by the application:<\/p>\n
cd rocketchat\/programs\/server\r\nnpm install<\/pre>\nIn order to start Rocket.Chat, we have to set the environment variables (as shown below):<\/p>\n
cd \/opt\/rocketchat\/rocketchat\r\nexport ROOT_URL=http:\/\/yourdomain.com<\/span>:3000\/\r\nexport MONGO_URL=mongodb:\/\/localhost:27017\/rocketchat\r\nexport PORT=3000<\/pre>\nDon’t forget to replace ‘yourdomain.com<\/code>‘ with your actual domain name.<\/p>\nAnd finally, start Rocket.Chat using the following command:<\/p>\n
node main.js<\/pre>\nOnce Rocket.Chat is successfully started, you will get text output that looks similar to the following:<\/p>\n
+-----------------------------------------------------------------------+\r\n| SERVER RUNNING |\r\n+-----------------------------------------------------------------------+\r\n| |\r\n| Rocket.Chat Version: 0.74.3 |\r\n| NodeJS Version: 8.11.3 - x64 |\r\n| Platform: linux |\r\n| Process Port: 3000 |\r\n| Site URL: http:\/\/yourdomain.com:3000\/ |\r\n| ReplicaSet OpLog: Disabled |\r\n| Commit Hash: 202a465f1c |\r\n| Commit Branch: HEAD |\r\n| |\r\n+-----------------------------------------------------------------------+<\/pre>\nYou can also configure Rocket.Chat to run as a service. Create a unit file like in Step 2<\/strong> using your preferred text editor.<\/p>\nnano \/etc\/systemd\/system\/rocketchat.service<\/pre>\nThen add the following contents to the file:<\/p>\n
[Unit]<\/pre>\nDescription=RocketChat Server\r\nAfter=network.target remote-fs.target nss-lookup.target mongod.target\r\n\r\n[Service]\r\nExecStart=\/usr\/local\/bin\/node \/opt\/rocketchat\/rocketchat\/main.js \r\nRestart=always \r\nRestartSec=10 \r\nStandardOutput=syslog \r\nStandardError=syslog \r\nSyslogIdentifier=nodejs-example\r\n#User=\r\n#Group=\r\nEnvironment=NODE_ENV=production PORT=3000 ROOT_URL=http:\/\/yourdomain.com MONGO_URL=mongodb:\/\/localhost:27017\/rocketchat\r\n\r\n[Install]\r\nWantedBy=multi-user.target<\/pre>\nSave and exit the file, then reload the units:<\/p>\n
systemctl daemon-reload<\/pre>\nOnce this is done, you can start the Rocket.Chat service and enable it to start upon a reboot:<\/p>\n
systemctl enable rocketchat\r\nsystemctl start rocketchat<\/pre>\nNow you will be able to access Rocket.Chat and complete the installation at http:\/\/yourdomain.com:3000<\/code> . The installation wizard will guide you through setting up your first administrative user, configuring your organization, registering your server to receive free push notifications, and more.<\/p>\nFore more information on how to use and configure Rocket.Chat. Please check their official documentation.<\/p>\n
\n Of course, you don\u2019t have to install Rocket.Chat on Ubuntu 18.04 if you use one of our Managed Ubuntu Hosting<\/a> plans, in which case you can simply ask our expert Linux admins to install Rocket.Chat on Ubuntu 18.04 for you. They are available 24\u00d77 and will take care of your request immediately.<\/p>\nPS.<\/span> <\/strong>If you liked this post on how to install Rocket.Chat on Ubuntu 18.04, please share it with your friends on the social networks using the share shortcuts below, or simply leave a comment down in the comments section. Thanks.<\/p>\n","protected":false},"excerpt":{"rendered":"In this tutorial, we will guide you through the process of installing Rocket.Chat on an Ubuntu 18.04 VPS. Rocket.Chat is … <\/p>\n
Read More<\/a><\/p>\n","protected":false},"author":4,"featured_media":31361,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1698],"tags":[1741,59],"yoast_head":"\nHow to Install Rocket.Chat on Ubuntu 18.04 - RoseHosting<\/title>\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\t \n\t \n\t \n \n \n \n \n \n\t \n\t \n\t \n