Ok I got this working mostly with help from the following instructions: http://code.google.com/p/modwsgi/wiki/InstallationOnFreeBSD
Here's what I did (as root user):
I already had apache22 installed from a binary package but apparently the package version is compiled without thread support and you need threads for mod_wsgi. So I did:
pkg_delete apache-2.2.17_1. This complained about php depending on apache, so I did:
pkg_delete php5-5.3.5. Then I did
pkg_delete apache-2.2.17_1 again which worked. Then I did
cd /usr/ports/www/apache22 then
make config then I checked the check box
"[X] THREADS Enable threads support in APR" then
make install. Starting apache worked but I got an error "[warn] (2)No such file or directory: Failed to enable the 'httpready' Accept Filter". I searched online and fixed it by doing
kldload accf_http and
apachectl restart then I added accf_http_load="YES" to my /boot/loader.conf so this change would persist after reboot.
this automatically modified my httpd.conf file to add a loadmodule line
(not strictly necessary but since I had to deinstall it above)
make config (and set any options desired)
Test mod_wsgi install
Following instructions at http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide.
I created a file called test.wsgi with the following content in my document root:
def application(environ, start_response):
status = '200 OK'
output = 'Hello World!'
response_headers = [('Content-type', 'text/plain'),
I added the following line to the end of my httpd.conf:
WSGIScriptAlias /myapp /usr/home/myusername/www/wsgitest/test.wsgi
(On my test box I have apache setup with a document root at /usr/home/myusername/www). Then I did apachectl restart. Then I went to http://localhost/myapp in my browser and voila! I saw "Hello World".
Refreshed my shell so path would update.
pip install django
(this got me django version 1.3 yay!)
to confirm django install
Create django test app
I created a new folder for my django test
mkdir /usr/home/myusername/www/djangotest. Then
django-admin.py startproject mysite
Create django wsgi file
created a new file /usr/home/myusername/www/djangotest/django.wsgi with the following content:
path = '/usr/home/myusername/www/djangotest'
if path not in sys.path:
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
application = django.core.handlers.wsgi.WSGIHandler()
WSGIScriptAlias /djangotest /usr/home/myusername/www/djangotest/django.wsgi
visit http://locahost/djangotest in browser. It works!
Edit httpd-vhosts.conf (optional)
Now to get it working as part of virtual host. Comment out the WSGIScriptAlias line in httpd.conf. Then add something like:
WSGIScriptAlias / /usr/home/myusername/www/djangotest/django.wsgi
After configuring hosts file, visit http://mytest.whatever in browser. It works!