0

I have read this. So, I install mod_wsgi, virtualenv(virtualenv ENV). (Django 1.4, ubuntu server)

/etc/apache2/sites-available/mysite:

<VirtualHost *:80>
ServerName www.example.com
ServerAlias example.com
WSGIDaemonProcess example.com python-path=/home/user/cars/cars:/home/user/cars/ENV/lib/python2.7/site-packege
WSGIScriptAlias / /home/user/cars/cars/wsgi.py
<Directory /home/user/cars/cars>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
</VirtualHost>
WSGIPythonPath /home/user/cars/ENV/lib/python2.7/site-packeges

I have Internal Server Error

in /var/log/apache2/error.log:

mod_wsgi (pid=3012): Exception occurred processing WSGI script '/home/user/cars/cars/wsgi.py'.
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 219, in __call__
self.load_middleware()
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 39, in load_middleware
for middleware_path in settings.MIDDLEWARE_CLASSES:
File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 184, in inner
self._setup()
File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 42, in _setup
self._wrapped = Settings(settings_module)
File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 95, in __init__
raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
ImportError: Could not import settings 'cars.settings' (Is it on sys.path?): No module named cars.settings

Please, help me, I have never configure Django with mod_wsgi. Its my first project

Update:

Alias /favicon.ico /home/user/cars/files/static_content/favicon.ico 
AliasMatch ^/([^/]*\.css) /home/user/cars/files/static_content/css/$1 
Alias /static/ /home/user/cars/files/static_content/ 
<Directory /home/user/cars/files/static_content> 
 Order deny,allow
 Allow from all 
</Directory>
2
  • Please post your wsgi.py. Obviously your project isn't on sys.path. Commented Oct 28, 2012 at 21:28
  • BTW, is it a bad cut and paste, or do you really have packages spelt wrong in both python-path and WSGIPythonPath? Commented Oct 29, 2012 at 1:57

1 Answer 1

1

You are missing the WSGIProcessGroup directive and so the WSGIDaemonProcess and its python-path option are not being used. The path set in WSGIPythonPath (which is for embedded mode only) is being used and in it you have not set the location of your project. Even for python-path to WSGIDaemonProcess you have the path wrong anyway.

Try with:

<VirtualHost *:80>
ServerName www.example.com
ServerAlias example.com
WSGIDaemonProcess example.com python-path=/home/user/cars:/home/user/cars/ENV/lib/python2.7/site-packages
WSGIProcessGroup example.com
WSGIScriptAlias / /home/user/cars/cars/wsgi.py
<Directory /home/user/cars/cars>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
</VirtualHost>

noting the change to python-path and addition of WSGIProcessGroup.

Sign up to request clarification or add additional context in comments.

2 Comments

yes, it works :) But I have one more truble: in cars I have dir 'files' and subdir 'static_content'. I use python manage.py collectstatic and it collects all static files to that directory. In Virtual host I have: (I update my first post). But it doesnt work (404 for css and img files). How to fix it?
If you got to the exact expected URL of the static file, what does Apache say in its error log file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.