Skip to content

Instantly share code, notes, and snippets.

@viperfx
Created June 22, 2014 18:48
Show Gist options
  • Save viperfx/cce17510e29b32229d33 to your computer and use it in GitHub Desktop.
Save viperfx/cce17510e29b32229d33 to your computer and use it in GitHub Desktop.
Linode Server Setup
#!/bin/bash
# APT Packages
apt-get -y update
apt-get install -y aptitude
aptitude install -y unattended-upgrades
aptitude install -y build-essential libssl-dev libexpat1-dev pkg-config
aptitude install -y git-core nginx
aptitude install -y monit
# set up automatic security updates
cat > /etc/apt/apt.conf.d/10periodic <<EOF
APT::Periodic::Enable "1";
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "1";
APT::Periodic::AutocleanInterval "5";
APT::Periodic::Unattended-Upgrade "1";
APT::Periodic::RandomSleep "1800";
EOF
# nodejs
wget wget http://nodejs.org/dist/v0.10.26/node-v0.10.26.tar.gz
tar -zxvf node-v0.10.26.tar.gz
pushd node-v0.10.26
./configure
make
make install
popd
rm -rf node-v0.10.26.tar.gz node-v0.10.26
# npm
curl http://npmjs.org/install.sh | sudo sh
# Setup basic nginx proxy.
unlink /etc/nginx/sites-available/default
cat > /etc/nginx/sites-available/node_proxy.conf <<EOF
server {
listen 80;
# proxy to node
location / {
proxy_pass http://127.0.0.1:3000/;
}
}
EOF
ln -s /etc/nginx/sites-available/node_proxy.conf /etc/nginx/sites-enabled/node_proxy.conf
/etc/init.d/nginx restart
#!upstart
#/etc/init/sitename.conf
description "Sitename"
start on (local-filesystems and net-device-up IFACE=eth0)
stop on shutdown
respawn # restart when job dies
respawn limit 5 60 # give up restart after 5 respawns in 60 seconds
script
exec node /var/www/appname >> /var/www/appnamelogs/upstart.log 2>&1
end script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment