简体   繁体   中英

Deploying Django project on Apache using Mod_wsgi

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM