Installing server packages for Ubuntu 18.04 VPS



Updating the local package index. 

$ sudo apt update

Error: Could not get lock /var/cache/apt/archives/lock - open (11: Resource temporarily unavailable)

The problem is that some apt processes are running, so using the "killall" command:

$ sudo killall apt-get

Or to remove the locking file.

$ sudo rm /var/lib/apt/lists/lock
$ sudo rm /var/cache/apt/archives/lock
$ sudo rm /var/lib/dpkg/lock

Error: apt-get update "the following signatures couldn’t be verified because the public key is not available"

Solve: Upgrading the entire system and importing your missing keys.

$ sudo apt-get upgrade
$ sudo apt-key adv --keyserver --recv-keys <YOUR_MISSING_KEY>


Installing nginx by command:

$ sudo apt install nginx

Afterwards, you must adjusting the firewall.

Firstly, list the application that ufw knowns by typing

$ sudo ufw app list

As you can see, there are three available options for enable:

Available applications:
 Nginx Full
 Nginx HTTP
 Nginx HTTPS

Because, we haven't configured SSL for the server yet, you will only need to allow HTTP traffic in port 80. By the way, you also need to allow OpenSSH traffic for remote control.

$ sudo ufw allow 'Nginx HTTP'
$ sudo ufw allow 'OpenSSH'

Enabling ufw firewall and displaying the result:

$ sudo ufw enable 
$ sudo ufw status


Version: 14.x

Following these commands:

$ curl -fsSL | sudo -E bash -
$ sudo apt-get install -y nodejs

You may also need development tools to build native addons:

sudo apt-get install gcc g++ make

To install the Yarn package manager, run:

$ curl -sL | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null
$ echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
$ sudo apt-get update && sudo apt-get install yarn

To check nodejs version, type:

$ node -v

Process Manager

In this case, we are using pm2.

$ npm install pm2 -g


From client to server


From server to Github


$ ssh-keygen -t ed25519 -C ""

You just enter for skipping.

Adding SSH key to the ssh-agent:

$ eval "$(ssh-agent -s)"
$ ssh-add ~/.ssh/id_ed25519 # Replacing id_ed25519 by your filename

Cat and copy your public key

$ cat ~/.ssh/

Afterwards, it must be added to the Github account.

By: Vũ Anh Hào