Skip to content

Instantly share code, notes, and snippets.

@S-YOU
Forked from bjpcjp/nodejs setup on Dreamhost VPS
Created February 21, 2022 02:38
Show Gist options
  • Save S-YOU/8f8c69d301afc7b6c8e00480b085c0e1 to your computer and use it in GitHub Desktop.
Save S-YOU/8f8c69d301afc7b6c8e00480b085c0e1 to your computer and use it in GitHub Desktop.
1) Make a download dir to store the node source and download it.
mkdir downloads
cd downloads
git clone https://github.com/joyent/node.git
Find the latest version
2) List all of the tags in the repository, and check out the most recent.
git tag
git checkout v0.9.9
3) Make a local bin, configure, compile and install node
mkdir -p ~/usr/local/bin
./configure --prefix=~/usr/local
make
make install
4) Add new bin to path variable
export PATH=$PATH:$HOME/usr/local/bin
echo "export PATH=$PATH:$HOME/usr/local/bin" >> ~/.bashrc
echo "export PATH=$PATH:$HOME/usr/local/bin" >> ~/.bash_profile
5) Check whether Node is working, and whether it matches your repo checkout
node --version
6) Download and install node's NPM package manager. Use curl's -L option to follow redirects.
curl http://npmjs.org/install.sh -L | sh
7) Installed correctly?
npm --version
8) Use "forever" to deploy node apps.
npm install -g forever
9) To start node as a daemon with forever:
forever start path/to/server.js
Forever will keep the node daemon running as long as the server stays up.
We need one more thing to restart the node daemon if the server is restarted.
To do this we will add a cron job to start the node daemon after the server is restarted.
@restart path/to/forever start path/to/server.js
You can get the path to forever by running
which forever
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment