First we consider the development environment.
It will be done using virtualbox + vagrant + ubuntu14.04
- Inside develop environment nginx (install using ubuntu repositories):
########################################
## Nginx
########################################
apt-get install \
nginx \
-y
## basic django app nginx config
read -r -d '' FILECONTENT <<'ENDFILECONTENT'
## create socket connection
## between nginx and uwsgi
## typically put the .sock
## in the webapp folder
upstream django {
server unix:/src/uwsgi.sock;
}
## listening
server {
listen 80 default_server;
server_name localhost;
charset utf-8;
error_log /var/log/nginx/django-app.log;
location / {
uwsgi_pass django;
include /src/nginx_configuration/uwsgi_params;
}
location /static {
alias /src/www/static;
}
location /media {
alias /src/www/media;
}
}
ENDFILECONTENT
echo "$FILECONTENT" > /etc/nginx/sites-available/django-app.conf
/etc/init.d/nginx restart
- install postgres (using ubuntu repositories) :
########################################
## PostgreSQL
########################################
sh -c "echo 'deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main' > /etc/apt/sources.list.d/pgdg.list"
wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | apt-key add -
apt-get update -y
apt-get install \
postgresql-common \
postgresql-9.3 \
libpq-dev \
-y
- Install python2
apt-get install python-virtualenv -y ## for virtualenv
apt-get install virtualenvwrapper -y ## for virtualenvwrapper
apt-get install python-setuptools -y ## for python2.7 or above
apt-get install python-dev -y ## ubuntu 14.04 no dev for python 2
apt-get install links -y ##a command line web browser
apt-get install python-flup -y ## connects python to uwsgi)
apt-get install build-essential -y
- Or install python3
apt-get install python-virtualenv -y ## for virtualenv
apt-get install python3-setuptools -y ## for python2.7 or above
apt-get install python3-dev -y ## ubuntu 14.04 no dev for python 3
apt-get install links -y ##a command line web browser
apt-get install python-flup -y ## connects python to uwsgi)
apt-get install build-essential -y
- Install supervisord
apt-get install supervisor -y
## Basic Configuration
read -r -d '' FILECONTENT <<'ENDFILECONTENT'
[program:app-uwsgi]
command = /usr/local/bin/uwsgi --ini /var/virtual/appname/uwsgi.ini
[program:nginx-app]
command = /usr/sbin/nginx
ENDFILECONTENT
echo "$FILECONTENT" > /etc/supervisor/conf.d/supervisord.conf