Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

when configuring mod_wsgi for django 1.4 apache fails to start on mac osx after adding WSGIPythonPath to the virtual host config

I followed the django docs on how to deploy django 1.4 to apache using mod_wsgi https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/modwsgi/ on mac osx lion and when I add the WSGIPythonPath directive apache cant restart .Yet without it my app is non existant in the path . In the log I am getting an error that reads

WSGIPythonPath cannot occur within VirtualHost section

here is what my virtual host config looks like

<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/Users/jamo/code/work/projects/bfpd/fapp"
ServerName bfpd.dev
ServerAlias bfpd.dev
ErrorLog "/private/var/log/apache2/bfpd.dev-error_log"
CustomLog "/private/var/log/apache2/bfpd.dev-access_log" common
Alias /static/ /Users/jamo/code/work/projects/bfpd/fapp/fapp/static/
<Directory /Users/jamo/code/work/projects/bfpd/fapp/fapp/static>
  Options Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    AllowOverride All
    Order allow,deny
    Allow from all
IndexOptions FancyIndexing
</Directory>
WSGIScriptAlias / /Users/jamo/code/work/projects/bfpd/fapp/fapp/wsgi.py
WSGIPythonPath /Users/jamo/code/work/projects/bfpd/fapp/  
    <Directory /Users/jamo/code/work/projects/bfpd/fapp/fapp>
    Options Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    AllowOverride All
    Order allow,deny
    Allow from all
    </Directory>

   </VirtualHost>

what am i doing wrong ???

like image 389
James Muranga Avatar asked Jun 08 '12 20:06

James Muranga


2 Answers

As mentioned in the comment by nemesisfixx, and specified by the error in your original question:

WSGIPythonPath cannot occur within VirtualHost section

Moving WSGIPythonPath outside of VirtualHost resolved Apache crashing on OS X server.

$ cat sites/0000_any_80_mysite.com.conf
WSGIPythonPath /Library/Server/Web/Data/Sites/mysite/django-app:/Users/owen/.virtualenvs/mysite:/Users/owen/.virtualenvs/mysite/lib/python2.7/site-packages

<VirtualHost *:80>
    ServerName mysite.com
    ServerAdmin [email protected]
    DocumentRoot "/Library/Server/Web/Data/Sites/mysite/site"
    ...
    WSGIScriptAlias /api /Library/Server/Web/Data/Sites/mysite/django-app/mysite/wsgi.wsgi
    ...
<VirtualHost>

It took a lot of putzing for me to get the paths correct (including full path to site-env, which I initially thought would be included automatically after adding the virtualenv top level).

like image 193
owenfi Avatar answered Oct 15 '22 07:10

owenfi


I fixed it. WSGIPythonPath /Users/jamo/code/work/projects/bfpd/fapp/ should be in http.conf

like image 37
James Muranga Avatar answered Oct 15 '22 07:10

James Muranga