Skip to content

Instantly share code, notes, and snippets.

@bjpcjp
Last active December 14, 2023 02:48
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bjpcjp/5349e0b3f07f05baf6ab to your computer and use it in GitHub Desktop.
Save bjpcjp/5349e0b3f07f05baf6ab 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
@Shiv2195
Copy link

Where to add the 9th command?

@blinqwebstudio
Copy link

path/to/forever start path/to/server.js caused node to look for package.json in / instead of in /path/to/ which caused an error that stopped the application.
Solved this by using --sourceDir likes so:
/path/to/forever start --sourceDir /path/to/application server.js
Reference: foreversd/forever#270 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment