-
-
Save frnhr/b9d597458c73c7a33f1bc18f0dc652e5 to your computer and use it in GitHub Desktop.
Using node.js in webfaction
This file contains hidden or 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
#taken from //community.webfaction.com/questions/4888/install-nodejs-with-express-framework | |
#the "forever" part taken from //shkfon.tumblr.com/post/27178918675/real-world-nodejs-part-1 | |
#thanks to [Ryan s](http://community.webfaction.com/users/16/ryans/) and [Dave Stevens](http://shkfon.tumblr.com/) | |
mkdir -p $HOME/src | |
cd $HOME/src | |
wget 'http://nodejs.org/dist/v0.8.9/node-v0.8.9.tar.gz' | |
tar -xzf node-v0.8.9.tar.gz | |
cd node-v0.8.9 | |
# All of these scripts use "#!/usr/bin/env python". Let's make that mean python2.7: | |
PATH_BACKUP="$PATH" | |
mkdir MYPY | |
ln -s $(which python2.7) $PWD/MYPY/python | |
export PATH="$PWD/MYPY:$PATH" | |
./configure --prefix=$HOME | |
make # 5.5m | |
make install | |
# restore the PATH (we don't need `$PWD/MYPY/python` anymore). | |
# Then, make sure $HOME/bin is on the PATH | |
PATH="$PATH_BACKUP" | |
export PATH=$HOME/bin:$PATH | |
echo 'export PATH="$HOME/bin:$PATH"' >> $HOME/.bashrc | |
hash -r | |
# Set the node modules path | |
export NODE_PATH="$HOME/lib/node_modules:$NODE_PATH" | |
echo 'export NODE_PATH="$HOME/lib/node_modules:$NODE_PATH"' >> $HOME/.bashrc | |
# now install express framework | |
cd $HOME | |
npm install -g forever | |
npm install -g express | |
npm install -g stylus | |
npm install -g jade | |
# create express framework "hello world" project | |
mkdir -p $HOME/node_projects | |
cd $HOME/node_projects | |
express -s -c stylus helloworld | |
cd helloworld | |
# use the PORT from your Custom Application created at the beginning! | |
PORT=8888 | |
sed -i "s/app.set('port', process.env.PORT || 3000);/app.set('port', process.env.PORT || $PORT);/" app.js | |
# run it | |
cd $HOME/node_projects/helloworld | |
forever start app.js |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment