Last active
December 6, 2024 23:31
-
-
Save bjpcjp/5349e0b3f07f05baf6ab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
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
Where to add the 9th command?