-
-
Save shagamemnon/215656d501f137cf9caca2ce10c1c8ce to your computer and use it in GitHub Desktop.
Configure NodeJs + NPM + NGINX
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
#!/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