Install Node.js on Alibaba Cloud

Image for post
Image for post

By Arslan Ud Din Shafiq, Alibaba Cloud Community Blog author and Alibaba Cloud MVP.

Node.js is an open-source cross-platform environment for JavaScript that allows you to run JS code outside the browser. Node.js also allows you to run scripts on server side for producing dynamic webpages. Rather than using different server side and client-side languages, by using Node.js alone, you can unify your web application around a single programming language — adding a whole lot of convenience to your workload.

In this tutorial, you will be installing and setting up Node.js on an Alibaba Cloud Elastic Compute Service (ECS) instance with Ubuntu 16.04.

Prerequisites

  • You must have Alibaba Cloud Elastic Compute Service (ECS) activated and verified your valid payment method. If you don’t know how to setup your ECS instance, you can refer to this tutorial or quick-start guide. Your ECS instance must have at least 1GB RAM and 1 Core processor.
  • A domain name registered from Alibaba Cloud. If you have already registered a domain from Alibaba Cloud or any other host, you can update its domain nameserver records.
  • Domain name must be pointed to your Alibaba Cloud ECS’s IP address
  • Access to VNC console in your Alibaba Cloud or SSH client installed in your PC
  • Set up your server’s hostname and create user with root privileges.

Setting up Your Environment

Setting up Your Server

Before proceeding with installation of any kind of package, run the following command to update your Ubuntu system. To run this command, remember to login from non-root user with sudo privileges.

Installing software-properties-common

Software-properties-common package is required to get the supported files for installation of Docker CE. In order to install software-properties-common package, follow the steps below.

To install software-properties-common, run the following command.

Installing apt-transport-https

Apt-transport-https is required for installation of Docker CE. In order to install apt-transport-https, complete the steps below.

To install apt-transport-https, run the command below.

Installing ca-certificates

Ca-certificates is required for installation of Docker CE. In order to install ca-certificates, follow the steps below.

To install ca-certificates, run the command.

Installing Curl

Curl is required for installation of Docker CE. In order to install curl, follow the steps below.

To install curl, run the command.

Installing Docker CE

To install Docker community edition, complete the steps below:

Add GPG key for Docker by running the command below.

Run the following command to verify the fingerprint of GPG key.

Now add the Docker repository by running the command below.

Update your system by running the command below to load added repository.

Run the following command to install Docker.

Add your username to docker group by running the command below.

Close your current shell session and start a new session because, otherwise, you won’t be able to run docker and you may see permission errors.

Next, run the following command to check either docker run correctly or not.

Installing Docker Compose

To download and install Docker compose, follow the steps below.

Run the following command to download and install latest version of docker compose.

Set the permissions for file by running the command below.

Get list of started containers by running the following command.

Image for post
Image for post

Stop container using port 8080. To do so, get container id, replace it with 8baab990c424 below and run the command below.

Installing and Setting up Node.js

In this tutorial specifically, I will use official image of Node.js for installation on Docker. To download and install Node.js, you will need to run the following command which will pull latest Nodejs from official docker repository.

Now run the following command to run docker image.

Now you can verify it by accessing your Alibaba Cloud ECS IP address or domain name pointing to that IP address. http://your_domain.tld/test.htm

You will see the following page.

Image for post
Image for post

Setting up Firewalls and Ports

If you have activated firewalls, you will have to define a rule in Alibaba Cloud security group for your cloud server to add exception for port 80/tcp and 443/tcp. You can enable these ports while creating ECS instance, but in case if you forgot to unblock these ports, you can follow the procedure in this guide: Add security group rules

Original Source

Written by

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