This is the configuration of my Fedora 15 staging server.
- VirtualEnv to isolate the environment.
- Gunicorn to serve the Django WSGI app.
- Supervisor to keep the Gunicorns running.
- Nginx to proxy requests to the Gunicorns.
# Create an isolated environment.
$ sudo yum install python-virtualenv
$ virtualenv --no-site-packages --python=python2.7 hunchworks
$ cd hunchworks
$ source bin/activate
# Grab the latest source from GitHub.
$ sudo yum install git
$ git clone git://github.com/global-pulse/HunchWorks.git src
$ cd src
# Install dependencies with Pip.
$ pip install -r requirements.txt
$ pip install gunicorn
# Spawn the SQLite database.
$ ./manage.py syncdb
# Install Supervisor.
# (See below for config.)
$ sudo yum install supervisor
$ sudo /etc/init.d/supervisord start
$ sudo chkconfig --levels 235 supervisord on
# Install Nginx.
# (See below for config.)
$ sudo yum install nginx
$ sudo /etc/init.d/nginx start
$ sudo chkconfig --levels 235 nginx on
# Open port 80.
$ sudo yum install lokkit
$ sudo lokkit -p http:tcp
[program:hunchworks]
directory=/home/adammck/hunchworks/src
command=/home/adammck/hunchworks/bin/gunicorn_django -b 0.0.0.0:8001
user=adammck
umask=022
autostart=True
autorestart=True
redirect_stderr=True
upstream hunchworks_server {
server 127.0.0.1:8001 fail_timeout=0;
}
server {
server_name hw.adammck.com;
listen 80;
location / {
proxy_pass http://hunchworks_server;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}