Skip to content

Instantly share code, notes, and snippets.

@ErisDS
Last active December 18, 2015 15:29
Show Gist options
  • Save ErisDS/b75be8bfe12c337a17bb to your computer and use it in GitHub Desktop.
Save ErisDS/b75be8bfe12c337a17bb to your computer and use it in GitHub Desktop.
Getting node & nginx installed on ec2
#!/bin/sh
apt-get update
# install node & npm
apt-get install -y python-software-properties python g++ make unzip
FORCE_ADD_APT_REPOSITORY=1 add-apt-repository ppa:chris-lea/node.js
apt-get update
apt-get install -y nodejs
# install nginx
FORCE_ADD_APT_REPOSITORY=1 add-apt-repository ppa:nginx/stable
apt-get update
apt-get install -y nginx
# configure nginx
#update-rc.d nginx defaults # not sure this is required
mkdir /var/www
chown ubuntu:www-data -R /var/www
chmod 0755 -R /var/www
rm -rf /etc/nginx/sites-enabled/default
mv /etc/nginx/sites-available/default /etc/nginx/sites-available/default.old
cat <<EOF >> /etc/nginx/sites-available/default
# Basic nginx config for a node.js server
server {
root /var/www;
index app.js;
server_name localhost;
location / {
proxy_pass http://127.0.0.1:3333;
expires 30d;
access_log off;
}
}
EOF
ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default
# restart nginx
service nginx restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment