last updated: 4/5/2011
note that this stuff is always a moving target, much of this has been cribbed and combined from various blog posts. Much of the information was out of date from those, and if it is more than a couple months after the last updated date above, consider some of this likely to now be out of date.
https://gist.github.com/902200:
mkdir -p ~/bin ~/lib/python2.6/site-packages easy_install-2.6 --prefix=$HOME pip pip install virtualenv
edit .bashrc and/or .bash_profile such that $HOME/bin and $HOME/sbin are on your path.
nginx and uwsgi can be shared among projects and do not need to be rebuilt for each site:
cd ~ mkdir tmp src bin sbin etc conf mylogs sock
http://nginx.org/en/download.html#stable_versions
cd src curl http://nginx.org/download/nginx-0.8.54.tar.gz | tar -xvz
http://projects.unbit.it/uwsgi/wiki/RunOnNginx
grab upload progress module:
http://github.com/masterzen/nginx-upload-progress-module
git clone https://github.com/masterzen/nginx-upload-progress-module.git
get uwsgi itself: I've found this latest version has compile errors on webfaction while this does not:
curl http://projects.unbit.it/downloads/uwsgi-0.9.6.8.tar.gz | tar -xz
build uwsgi:
cd uwsgi-x-x-x-x make -f Makefile.Py26 cp uwsgi $HOME/bin/
uwsgi module included by default in nginx since 0.8.40 so you do not need to specify it at configure time. Webfaction has sought to make the "logs" directory in your home folder owned by root - so we need to configure alternate log destinations.
build nginx:
cd ../nginx-0.8.54/ ./configure --add-module=../nginx-upload-progress-module/ \ --prefix=$HOME \ --error-log-path=$HOME/mylogs/nginx-error.log \ --lock-path=$HOME/mylogs/nginx.lock \ --pid-path=$HOME/mylogs/nginx.pid \ --http-log-path=$HOME/mylogs/nginx-access.log make make install
expect to see errors about deprecated sys_errlist: http://nginx.org/en/docs/sys_errlist.html
create custom port listening app:
cd webapps/<appname>/ virtualenv venv source venv/bin/activate
cd out to webapps/<appname> django-admin.py startproject test_project
get the django project settings and urls set up for admin to work
collect static files:
manage.py collectstatic
get project on python path:
cd venv/<site-packages> ln -s $HOME/webapps/<appname> .
start up nginx, note that it will not daemonize but can be started like this for testing:
nginx -p `pwd`/ -c ../test_project/etc/nginx.conf
create a wsgi.py file in project root:
import os os.environ['DJANGO_SETTINGS_MODULE'] = 'test_project.settings' import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler()
startup uwsgi, again, won't daemonize - you'll need two terminals to run both nginx and uwsgi in this test mode:
uwsgi -p 4 -s $HOME/sock/teststack_uwsgi.sock -H $HOME/webapps/teststack/venv/ --pythonpath $HOME/webapps/teststack/test_project -w wsgi
You should now be able to load up the Django-admin
create another custom port app in webfaction control panel
install supervisor with pip install supervisor
see supervisord.conf
see start_supervisor.sh
*/10 * * * * /home/ptone/bin/start_supervisor.sh start > /dev/null 2>&1 nohup start_supervisor.sh start