Updated on: 5.Dec.2020
Node.js
Node.js is a virtual machine to host JavaScript program. It is powerful such that you can write a simple website in a few lines of code.
- To install Node.js
cd ~
# download the setup script - you may review it before executing this script
curl -sL https://deb.nodesource.com/setup_14.x -o nodesource_setup.sh
sudo bash nodesource_setup.sh
sudo apt install nodejs
sudo apt install build-essential
- To check version,
node -v
npm -v
- To remove Node.js
sudo apt-get purge --auto-remove nodejs
PM2
The website that was developed in Node.js will be shut down upon server reboot. In this case, we need a program to start it and monitor the process. There are many options to achieve this. But, we choose PM2 due to it's flexibility and able to run on Windows platform.
- To install PM2
sudo npm install pm2@latest -g
- To install log rotate
sudo pm2 install pm2-logrotate
- Set as startup (in Linux) - run the following command in a NON root context,
sudo pm2 startup systemd
- The log files will be kept in the following directory
pm2 home directory: /home/<username>/.pm2
No comments:
Post a Comment