Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updates for Apache, mod_wsgi, Gunicorn, Mingus.

  • Loading branch information...
commit 4b33cf73128216b8ecc561e0d4397337f9638b98 1 parent c32e228
@jacobian jacobian authored
View
5 apache/apache2.conf
@@ -13,9 +13,6 @@ ServerAdmin someone@example.com
# Standalone server.
Listen *:80
-# To become a backend for a load balancer, uncomment below and fix the IP.
-# Listen 10.X.X.X:8000
-
#
# Worker MPM features
#
@@ -69,7 +66,7 @@ DocumentRoot "/home/web/static"
# And finally the app config.
#
-WSGIScriptAlias / "/home/web/django-deployment-workshop/fumblerooski-site/bin/django.wsgi"
+WSGIScriptAlias / "/home/web/myblog/mingus.wsgi"
View
28 fabfiles/single-server.py
@@ -1,37 +1,35 @@
"""
The tutorial's first fabfile: automate deployment onto a single server.
-If you have Fabric installed system-wide, run with::
+Run with::
- fab -f single-server.py <command>
-
-The buildout in ``fumblerooski-site`` has Fabric, too, so you can::
-
- fumblerooski-site/bin/fab -f ../fabfiles/single-server.py <command>
+ fab -f fabfiles/single-server.py <command>
+
+Expects to be run from the parent directory.
"""
-from __future__ import with_statement
-
import os
from fabric.api import *
# I have entries in /etc/hosts which make these names work.
# If I didn't, I'd just use IP addresses.
-env.hosts = ['oscon-web1']
+env.hosts = ['pyweb-web1']
env.user = 'root'
-env.code_root = "/home/web/django-deployment-workshop"
-env.buildout_root = os.path.join(env.code_root, "fumblerooski-site")
+# Constants for where everything lives on the server.
+env.root = "/home/web/myblog"
def push():
"Push out new code to the server."
with cd(env.code_root):
run("git pull")
+ put("mingus-config/web1.py", "%(root)s/django-mingus/mingus/settings.py" % env)
+ put("mingus-config/mingus.wsgi", "%(root)s/mingus.wsgi" % env)
-def buildout():
- "Run the buildout remotely."
- with cd(env.buildout_root):
- run("./bin/buildout")
+def update_dependencies():
+ "Update Mingus' requirements remotely."
+ put("mingus-config/requirements.txt", "%s/requirements.txt")
+ run("%(root)s/bin/pip install -r %(rot)s/requirements.txt" % env)
def reload():
"Reload Apache to pick up new code changes."
View
28 mingus-config/mingus.wsgi
@@ -0,0 +1,28 @@
+import os
+import site
+import sys
+
+# Add the virtualenv packages to the site directory. This uses the technique
+# described at http://code.google.com/p/modwsgi/wiki/VirtualEnvironments
+
+# Remember original sys.path.
+prev_sys_path = list(sys.path)
+
+# Add the virtualenv site-packages to the site packages
+site.addsitedir('/home/web/myblog/lib/python2.6/site-packages')
+
+# Reorder sys.path so the new directories are at the front.
+new_sys_path = []
+for item in list(sys.path):
+ if item not in prev_sys_path:
+ new_sys_path.append(item)
+ sys.path.remove(item)
+sys.path[:0] = new_sys_path
+
+# Add the app code to the path
+sys.path.append('/home/web/myblog/django-mingus')
+
+# Now do DJANGO_SETTINGS_MODULE and create the WSGI app.
+os.environ['DJANGO_SETTINGS_MODULE'] = 'mingus.settings'
+import django.core.handlers.wsgi
+application = django.core.handlers.wsgi.WSGIHandler()
View
43 mingus-config/requirements.txt
@@ -0,0 +1,43 @@
+BeautifulSoup>=3.0.8
+PIL
+python-dateutil==1.4.1
+django==1.1.1
+django-debug-toolbar==0.8.1
+django-tagging==0.3
+Pygments==1.1.1
+FeedParser==4.1
+Markdown==2.0.1
+textile==2.1.3
+django-robots==0.6.1
+django-dbtemplates==0.6.1
+django-markup==0.3
+django-memcache-status==1.0.1
+
+-e git://github.com/django-extensions/django-extensions.git@459276ded0edf1d1cf6d94b4865891a281445b95#egg=django_extensions-0.4.2_pre-py2.5-dev
+-e git://github.com/montylounge/django-basic-apps.git@72ad0a50a464d3dd296a566f749e86b1f9080bac#egg=django_basic_apps-0.6-py2.5-dev
+-e hg+http://bitbucket.org/discovery/django-bitly/@6c6b6fe662cbe48325b902775fcf1eaacfd08181#egg=django_bitly-tip
+-e git://github.com/mintchaos/django_compressor.git@7f314c513410a5be6379edf1abfc4f1730a36d09#egg=django_compressor-0.5.1-py2.5-dev
+-e hg+https://bitbucket.org/ubernostrum/django-contact-form/@1d3791fa4dfbb2375ba0d27e62283380c0ec74e6#egg=django_contact_form-tip
+-e svn+http://django-db-log.googlecode.com/svn/trunk@13#egg=django_db_log-1.0.1-py2.5-dev_r13
+-e git://github.com/montylounge/django-disqus.git@35a022f28c50b9f7cdfcdd5deb4ae6f9150f4358#egg=django_disqus-0.1-py2.5-dev
+-e git://github.com/zerok/django-flatblocks.git@77c310727d5ec5a0f69cdeda2b71bea8613503f0#egg=django_flatblocks-0.3.3-py2.5-dev
+-e git://github.com/sunlightlabs/django-honeypot.git@76f57f487f68825fb302269516bb2b3284b81801#egg=django_honeypot-0.2.1-py2.5-dev
+-e svn+http://django-navbar.googlecode.com/svn/trunk@20#egg=django_navbar-0.1.1rc1-py2.5-dev_r20
+-e git://github.com/brosner/django-oembed.git@0b09321a6042c490534e5940083136f712da57b0#egg=django_oembed-0.1.0-py2.5-dev
+-e git://github.com/montylounge/django-proxy.git@37f5e24c4426aeec6fc20473d1213fafb6e5c489#egg=django_proxy-0.1.0-py2.5-dev
+-e git://github.com/montylounge/django-quoteme.git@d067a0da1756867250af9d836b8e0d47ff6c7c44#egg=django_quoteme-0.2-py2.5-dev
+-e git://github.com/hbussell/django-slimmer.git@61deecdbc7650664c2a23f36ed806c043c70d65e#egg=django_slimmer-0.0.1-py2.5-dev
+#-e hg+http://bitbucket.org/jezdez/django-staticfiles/@25e2c314aa665e855c4f242c374b2a27bd895542#egg=django_staticfiles-tip
+-e git+https://github.com/jezdez/django-staticfiles.git#egg=django_staticfiles-tip
+-e git://github.com/montylounge/django-sugar.git@fad43351d848da815159837d0a5f548b1fd2ef0f#egg=django_sugar-0.2-py2.5-dev
+-e svn+http://django-tinymce.googlecode.com/svn/trunk@96#egg=django_tinymce-trunk-py2.5-dev_r96
+-e git://github.com/skevy/django-twitter.git@887a017e0436b5e03aab96e5ba650696ab2d9b58#egg=django_twitter-0.1-py2.5-dev
+-e hg+https://bitbucket.org/kmike/django-view-cache-utils/@4408ad8f1751ee2fccb441d2a342c4ed710467a0#egg=django_view_cache_utils-tip
+-e git://github.com/pydanny/django-wysiwyg.git@b280e1b75326363dfe746d8c36425cfbed53b4ec#egg=django_wysiwyg-0.1.0-py2.5-dev
+-e git://github.com/montylounge/django-google-analytics.git@6b7aa6dba851dd59dca0a20bc7eefe70754384e4#egg=google_analytics-0.1-py2.5-dev
+-e hg+https://python-twitter.googlecode.com/hg/@7e5cb2db67352ac1fd7b40a3ec54fdef352f802f#egg=python_twitter-0.7_devel-py2.5-default
+-e svn+http://django-template-utils.googlecode.com/svn/trunk@109#egg=template_utils-0.4p2-py2.5-dev_r109
+-e git://github.com/montylounge/django_cropper.git@194e3c94b0abcb5ec2a9788ff1fe474779b3f67d#egg=django-cropper-0.1.5a-py2.5-dev
+-e git://github.com/kylef/django-request.git@84cfef56f6eea281a9c382859fb29ef570c7295d#egg=django_request-0.21-py2.5-dev
+
+sorl-thumbnail
View
0  mingus-config/web1.py
No changes.
View
0  mingus-config/web2.py
No changes.
View
54 notes/pycon2011/script.txt
@@ -10,6 +10,9 @@ sense without my narrative. However, for those not in the class, judicious use
of ``man`` and Google along with experimentation should make for an
interesting afternoon.
+All of the follow commands assume I'm running as root. Judicious use of
+``sudo`` would be required otherwise.
+
Pre-class
---------
@@ -29,21 +32,24 @@ Hosts file for easier web-ing::
33.33.33.10 pycon-web1
33.33.33.11 pycon-web2
33.33.33.20 pycon-db1
-
+
1. Getting started
------------------
Bootstrap up the example app::
web1$ mkdir -p /home/web
- web1$ sudo aptitude update
- web1$ sudo aptitude install git-core python-dev python-setuptools postgresql-dev postgresql-client build-essential libpq-dev subversion
- web1$ sudo easy_install virtualenv
+ web1$ aptitude update
+ web1$ aptitude install git-core python-dev python-setuptools \
+ postgresql-dev postgresql-client build-essential \
+ libpq-dev subversion mercurial
+ web1$ easy_install virtualenv
web1$ git clone git://github.com/jacobian/django-deployment-workshop.git
web1$ cd /home/web
web1$ virtualenv myblog
web1$ cd myblog
web1$ source bin/activate
+ web1$ pip install -U pip
web1$ git clone git://github.com/montylounge/django-mingus.git
web1$ cd django-mingus/mingus
web1$ pip install -r stable-requirements.txt
@@ -59,22 +65,22 @@ Get ``http://pycon-web1:8000/`` - bing!
Install and configure Postgres::
- db1$ sudo aptitude update
- db1$ sudo aptitude install git-core postgresql
+ db1$ aptitude update
+ db1$ aptitude install git-core postgresql
db1$ mkdir -p /home/web
db1$ cd /home/web
db1$ git clone git://github.com/jacobian/django-deployment-workshop.git
db1$ cd /etc/postgresql/8.4/main/
- db1$ sudo invoke-rc.d postgresql-8.4 stop
- db1$ sudo mv postgresql.conf postgresql.conf.orig
- db1$ sudo mv pg_hba.conf pg_hba.conf.orig
- db1$ ln -s /home/web/django-deployment-workshop/postgresql/postgresql.conf
+ db1$ invoke-rc.d postgresql-8.4 stop
+ db1$ mv postgresql.conf postgresql.conf.orig
+ db1$ mv pg_hba.conf pg_hba.conf.orig
+ db1$ ln -s /home/web/django-deployment-workshop/postgresql/postgresql.conf .
db1$ ln -s /home/web/django-deployment-workshop/postgresql/pg_hba.conf .
- db1$ sudo invoke-rc.d postgresql-8.4 start
+ db1$ invoke-rc.d postgresql-8.4 start
And create users and database. Root user for convenience::
- db1$ sudo -u postgres createuser vagrant
+ db1$ sudo -u postgres createuser root
db1$ createuser mingus
db1$ createdb -O mingus mingus
@@ -89,6 +95,30 @@ Hit ``http://pycon-web1:8000/`` -- *boom*.
3. Application servers: mod_wsgi, gunicorn
------------------------------------------
+Install Apache and mod_wsgi, and zap away all the Ubuntu cruft::
+
+ web1$ aptitude install apache2 libapache2-mod-wsgi
+ web1$ cd /etc/apache2/
+ web1$ rm -rf apache2.conf conf.d/ httpd.conf magic mods-* sites-* ports.conf
+
+Add our config. Remember to make a python eggs dir (it should be writable by
+apache, but 777 is easier)::
+
+ web1$ ln -s /home/web/django-deployment-workshop/apache/apache2.conf .
+ web1$ ln -s /home/web/django-deployment-workshop/mingus-config/mingus.wsgi \
+ /home/web/myblog/mingus.wsgi
+ web1$ mkdir -m777 -p /var/www/.python-eggs
+ web1$ invoke-rc.d apache2 restart
+
+Hit ``http://pycon-web1/`` -- *boom*.
+
+Now try it with Gunicorn::
+
+ web1$ pip install gunicorn
+ web1$ cd /home/web/myblog/django-mingus/mingus
+ web1$ vim settings.py # INSTALLED_APPS += "gunicorn"
+ web1$ ./manage.py run_gunicorn
+
4. Automation
-------------
Please sign in to comment.
Something went wrong with that request. Please try again.