Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

PM2

install

Ubuntu 22 ARM

1

wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
source .bashrc
nvm install --lts
nvm use --lts
npm install -g pm2
pm2 dump
pm2 startup
# pm2 unstartup
# Restore from dump file after reboot
pm2 resurrect

config

Windows 10

set "PM2_HOME=C:\ProgramData\pm2\home"
set "PM2_INSTALL_DIRECTORY=C:\ProgramData\npm\npm\node_modules\pm2"
set "PM2_SERVICE_DIRECTORY=C:\ProgramData\pm2\service"

Configuare Apache on Rocky Linux

2 3

pm2 start npm --name "<app_name>" --watch -- start

Create a new VirtualHost configuration with subdomain names:

sudo vim /etc/httpd/conf.d/sub.domain.com.conf
<VirtualHost *:80>
  ServerName www.sub.domain.com
  ServerAlias sub.domain.com

  ErrorLog /var/log/httpd/sub.domain.com-error.log
  CustomLog /var/log/httpd/sub.domain.com-access.log combined
  ProxyPreserveHost On
  ProxyPass / http://localhost:3000/
  ProxyPassReverse / http://localhost:3000/
</VirtualHost>

reference

cross-reference


  1. Persistent applications

  2. How to specify a port number for pm2

  3. How to change the port in nextjs?