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.


  • 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

# sudo apt update && sudo apt upgrade

Installing software-properties-common

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

# sudo apt-get install software-properties-common -y

Installing apt-transport-https

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

# sudo apt-get install apt-transport-https -y

Installing ca-certificates

To install ca-certificates, run the command.

# sudo apt-get install ca-certificates -y

Installing Curl

To install curl, run the command.

# sudo apt-get install curl -y

Installing Docker CE

Add GPG key for Docker by running the command below.

# curl -fsSL | sudo apt-key add -

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

# sudo apt-key fingerprint 0EBFCD88

Now add the Docker repository by running the command below.

# sudo add-apt-repository "deb [arch=amd64] $(lsb_release -cs) stable"

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

# sudo apt update

Run the following command to install Docker.

# sudo apt install docker-ce

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

# sudo adduser aareez docker

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.

# docker run hello-world

Installing Docker Compose

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

# sudo curl -L`uname -s`-`uname -m` -o /usr/local/bin/docker-compose

Set the permissions for file by running the command below.

# sudo chmod +x /usr/local/bin/docker-compose

Get list of started containers by running the following command.

# docker container ls --all
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.

# docker stop 8baab990c424

Installing and Setting up Node.js

# docker pull linode/server-node-js

Now run the following command to run docker image.

# docker run -d -p 80:3000 linode/server-node-js

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

Original Source

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