Skip to content

Instantly share code, notes, and snippets.

@crullian
Created November 12, 2016 04:28
Show Gist options
  • Save crullian/3ca7814565cc96ef3ff1d4c2fe4fb07c to your computer and use it in GitHub Desktop.
Save crullian/3ca7814565cc96ef3ff1d4c2fe4fb07c to your computer and use it in GitHub Desktop.
Node on Dreamhost
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