pm2
pm2 copied to clipboard
install pm2 for all user.
how to install pm2 for all user.
There are two user "dev and gen"
how to install pm2 with user dev? and the user gen can direct use pm2
I solved it by installing pm2 and then make an alias which runs it as one user
alias pm2='sudo -u node /usr/bin/pm2'
which i put in an shell configuration file everybody read for example /etc/profile.d/pm2.sh
how do you installing pm2?
In fact, I want to let all user use "one pm2" So, the process that pm2 list should be the same process.
I install it with sudo rpm -g i pm2
so it gets globally installed. I then have one account node who nobody uses directly it is only used to run pm2. The alias I mentioned above runs pm2 as the user node (-u node). So writing pm2 list
is really sudo -u node /usr/bin/pm2 list
You don't have to name the account node. It could be anything.
Hi @johandalabacka Thanks for your reply
I use this to install pm2 It will generate /home/"$USER"/.pm2 Where is the rpm generate
npm install -g pm2
by the way, I use npn install pm2 and the nvm is install on /home/"$USER"/.nvm Does it cause the the pm2 install on /home/"$USER"/.nvm/*//pm2 ?
Hi. Is this on a production server? maybe you shouldn't use nvm or at least read up on using nvm in a multiuser enviroment. We install node as a package on our server so all globally installed packages are put in the same folder and not in someones library.
I just follow the step https://www.makeuseof.com/how-to-install-and-set-up-pm2-on-linux-servers/ to install nvm and pm2. Then they are put in someones library.
Do you have the the script to install node ? I appreciate your help very much.
We install node as a package on our server so all globally installed packages are put in the same folder
hi @alicera, for installing node, i would also suggest nvm,
installing nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash
exit and start the terminal again
install lts version of the node
nvm install --lts
using node's latest version
nvm use lts/*
installing pm2
npm i -g pm2
getting pm2 path
which pm2
using command suggested by @johandalabacka
alias pm2='sudo -u node /usr/bin/pm2'
in place of /usr/bin/pm2 put the path you get using which command
thanks
Using the root user, install the PM2 library globally. Create the necessary users and execute this command.
n=$(which pm2);n=${n%/bin/pm2}; chmod -R 755 $n/bin/*; sudo cp -r $n/{bin,lib,share} /usr/local