You have to learn to use pm2 :
- You should be able to install nvm in your ubuntu, centos etc.. via ssl:
from https://github.com/nvm-sh/nvm
- nvm will give you possibilities to install node
- After you complete the installation of node, install pm2 globally,
- https://pm2.keymetrics.io/
- At root dir of project create file : ecosystem.config.js
ecosystem.config.js :
module.exports = {
apps : [
{
name: "your_server_name",
script: "./server.js",
watch: true,
env_development: {
"PORT": 3000,
"NODE_ENV": "development"
},
env_production: {
"PORT": 8001,
"NODE_ENV": "production",
}
}
]}
.htaccess look like this :
DirectoryIndex disabled
RewriteEngine On
RewriteRule ^$ http://127.0.0.1:8001/ [P,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://127.0.0.1:8001/$1 [P,L]
Login to your site over SSH:
ssh name@IP then password
How to run pm2 .
pm2 start ecosystem.config.js --env production
pm2 start ecosystem.config.js --env development
Which files u need in server :
