Deploy NodeJS website
Suppose you have a nodejs website that you want to run under domain api.domain.com
Make sure the two applications
NodeJS
andPM2
are installed on the serverCreate a website with the following configuration
- Enter domain
- Select Proxy Port
- Enter the port your nodejs application runs on, for example 3000
Install the source code for the website from git or upload it yourself
At local level, start nodejs with the command
node indexjs
Then in the production environment, I run the commandpm2 start index.js --name my-api
Next time you update new code, you just need to run the command again
pm2 restart my-api