Skip to content

Instantly share code, notes, and snippets.

@shagamemnon
Forked from carlosvillu/install_node.sh
Last active July 13, 2018 03:05
Show Gist options
  • Save shagamemnon/215656d501f137cf9caca2ce10c1c8ce to your computer and use it in GitHub Desktop.
Save shagamemnon/215656d501f137cf9caca2ce10c1c8ce to your computer and use it in GitHub Desktop.
Configure NodeJs + NPM + NGINX
#!/bin/bash
NODE_VERSION=0.4.10
NPM_VERSION=1.0.22
sudo apt-get update
sudo apt-get install -y build-essential git-core nginx libssl-dev pkg-config curl
# Install node
mkdir -p $HOME/local/node
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
./configure --prefix=$HOME/local/node
make
make install
cd
echo 'export PATH=$HOME/local/node/bin:$PATH' >> ~/.profile
echo 'export NODE_PATH=$HOME/local/node:$HOME/local/node/lib/node_modules' >> ~/.profile
source $HOME/.profile
# Setup basic nginx proxy.
cat > /etc/nginx/sites-available/node_proxy.conf <<EOF
server {
listen 80;
# proxy to node
location / {
proxy_pass http://127.0.0.1:1601/;
}
}
EOF
ln -s /etc/nginx/sites-available/node_proxy.conf /etc/nginx/sites-enabled/node_proxy.conf
/etc/init.d/nginx restart
# install npm
mkdir -p $HOME/local/npm
npm install npm@latest -g
cd npm
git checkout v$NPM_VERSION
./configure --prefix=$HOME/local/npm
make
make install
cd
echo 'export PATH=$HOME/local/npm/bin:$PATH' >> ~/.profile
source ~/.profile
# install npm packages
npm install -g express socket.io jade
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment