Installation node.js
Installation dependencies
sudo apt-get install g++ curl libssl-dev apache2-utils
sudo apt-get install git-core
Acquiring node source
git clone git: After the download is complete //github.com/joyent/node.git enter cd node into the node folder.
Specify the move version: git checkout v0.4.10, git is a version management tool, which we use git version 0.4.10 to move out, if you do not move out, then direct node will be installed to compile the latest version 0.5.5-pre. The latest version of many common package is not supported. Such as express, so be sure to pay attention to this place.
The development path, compile
mkdir ~/local
./configure –prefix=$HOME/local/node
make
make install
echo ‘export PATH=$HOME/local/node/bin:$PATH’ >> ~/.profile
echo ‘export NODEPATH=$HOME/local/node:$HOME/local/node/lib/nodemodules’ >> ~/.profile
source ~/.profile
Now we can run the node -v to see if the installation was successful. Note that this setting environment variables is only temporary.
Setting environment variables permanently
Setting environment variables permanently even restart the machine can also use the command node. Enter /etc/.profile in the rearmost two additional lines:
export PATH=”$HOME/local/node/bin:$PATH” export NODEPATH=”$HOME/local/node:$HOME/local/node/lib/nodemodules”
Install express
Installation npm: execute the command:
curl http://npmjs.org/install.sh | SH install express:
npm install express -gd
Try Express
Create the app:
$ npm install -g express $ express /tmp/foo && cd /tmp/foo
Install dependencies
npm install -d
Start the server
By POST: Jalen Wang ( please indicate the source )
Reproduced in: https: //www.cnblogs.com/jalenwang/archive/2012/04/28/express-ubuntu.html