0

I am deploying a Django project on Apache. and after configuration, I open the "localhost" in the browser, and nothing showed up and the status bar just keep saying "Waiting for localhost". Here is some info.

1.Environment:

OS: Red Hat Enterprise Linux Server x86
Python: 2.7.2
Django: 1.3.1
Mod_wsgi: 3.3
Apache: 2.2.21
Django project: /var/www/html/server/video1

2.Apache Config file lines added:

LoadModule wsgi_module modules/mod_wsgi.so
WSGIScriptAlias / /var/www/html/server/video1/apache/django.wsgi

Alias /media/ /usr/local/apache2/htdocs/media/
Alias /static/ /usr/local/apache2/htdocs/static/

<Directory "/var/www/html/server/video">
Order Deny,Allow
Allow from all
</Directory>
<Directory "/usr/local/apache2/htdocs/media">
Order Deny,Allow
Allow from all
</Directory>
<Directory "/usr/local/apache2/htdocs/static">
Order Deny,Allow
Allow from all
</Directory>

3.Django.wsgi file:

import os
import os.path
import sys

sys.path.append('/var/www/html/server')
sys.path.append('/var/www/html/server/video')

os.environ['DJANGO_SETTINGS_MODULE'] = 'video1.settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()   

4.settings.py lines added:

MEDIA_ROOT='/usr/local/apache2/htdocs/media/'
MEDIA_URL='/media/'
STATIC_ROOT='/usr/local/apache2/htdocs/static/'
STATIC_URL='/static/'
ADMIN_MEDIA_PREFIX='static/admin'

TEMPLATES_DIR = {
   "/var/www/html/server/video1/templates"
}

INSTALLED_APPS = {
   'django.contrib.admin'
}

5.restart apache

These are what I did, can someone help me to see if somewhere is wrong?

Thank you very much

4
  • Is your project working correctly under devserver? Does Apache listen to port 80? Commented Mar 8, 2012 at 19:03
  • Yes, the Django project works well under the devserver, and Apache works well on port 80 sololy, it just have problem when using mod_wsgi to build a link between them. Commented Mar 8, 2012 at 19:05
  • What does error_log/access_log say about this? Commented Mar 8, 2012 at 22:14
  • the error_log says Could not find platform independent libraries <prefix>; Could not find platform dependent libraries <exec_prefix>;Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]; ImportError: No module named site Commented Mar 8, 2012 at 23:09

1 Answer 1

2

The path '/var/www/html/server/video' doesn't match what you have in WSGIScriptAlias.

Besides that, did you actually try and deploy a WSGI hello world program first?

Also try setting LogLevel to info in Apache instead of warn. The Apache error log will then contain messages to say whether the WSGI script file is loaded. Right now not obvious whether your browser can't even contact server, or whether WSGI application loaded, but not responding.

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

4 Comments

Thank you, I checked the path, it was a typo, the path should be '/var/www/html/server/video1', sorry about this. and "setting LogLevel to info in Apache instead of warn", how to do that? I am new to all these stuff. Thanks
Find the existing entry in the Apache configuration file which said 'LogLevel info'. This presumes you didn't simply throw away the whole contents of the original Apache config, which is always a bad idea.
Thanks, I changed the loglevel and restart the apache and open the error log again and the saw couple of message saying "mod_wsgi: initializing python" besides "Could not find platform independent libraries <prefix>; Could not find platform dependent libraries <exec_prefix>;Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]; ImportError: No module named site"
Read code.google.com/p/modwsgi/wiki/… in case you need to set WSGIPythonHome.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.