Skip to content

Instantly share code, notes, and snippets.

@jamesjohnson
Created June 20, 2012 18:31
Show Gist options
  • Save jamesjohnson/2961433 to your computer and use it in GitHub Desktop.
Save jamesjohnson/2961433 to your computer and use it in GitHub Desktop.
Amazon AWS Server Setup
#!/usr/bin/bash
#This will set up your machine for using django 1.4
sudo add-apt-repository -y ppa:pitti/postgresql
sudo add-apt-repository -y ppa:git-core/ppa
sudo add-apt-repository -y ppa:bchesneau/gunicorn
sudo add-apt-repository -y ppa:nginx/stable
sudo add-apt-repository -y ppa:natecarlson/haproxy # For Load Balancing
sudo apt-get update -y
sudo apt-get install -y nginx memcached rsync libpq-dev python-dev libxslt1-dev libxml2-dev python-psycopg2 git-core redis-server postgresql-9.1 inetutils-syslogd apache2-utils python-pip libevent-dev
sudo pip install virtualenv gevent setproctitle django
sudo mkdir -p /var/log/django /var/log/gunicorn /var/run/gunicorn /var/www
sudo useradd -Ur gunicorn -d /var/run/gunicorn
sudo chown -R ubuntu:ubuntu /var/www
sudo chown -R gunicorn:gunicorn /var/log/django /var/log/gunicorn /var/run/gunicorn
sudo ln -s /etc/nginx/sites-enabled /etc/nginx/enabled
sudo ln -s /etc/nginx/sites-available /etc/nginx/available
sudo cat > /etc/nginx/nginx.conf <<EOF
user www-data;
worker_processes 1;
worker_rlimit_nofile 8192;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 2048;
# debug_connection 192.168.1.1;
# multi_accept on;
}
http {
server_tokens off;
include mime.types;
access_log /var/log/nginx/access.log;
sendfile on;
tcp_nodelay on;
gzip on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/enabled/*.ngx;
#tcp_nopush on;
#keepalive_timeout 0;
}
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment