Apache没有使用mod_wsgi为Django应用程序提供服务

时间:2014-11-15 17:39:58

标签: python django apache deployment mod-wsgi

所以这是我的Apache配置:

LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so

<VirtualHost *:80>
    ServerAdmin marijus.merkevicius@gmail.com
    ServerName 31.220.49.197
    WSGIDaemonProcess ts threads=25
    WSGIProcessGroup ts
    Alias /static /home/email-validator/static
    WSGIScriptAlias / /home/email-validator/index.wsgi

    # Set access permission
    <Directory />
        llow from all
        equire all granted
    </Directory>
</VirtualHost>

这是我的index.wsgi:

import os
import sys
import site

# Add the application's directory to the PYTHONPATH
sys.path.append('/home/email-validator')
sys.path.append('/home/email-validator/email_validator')

os.environ['DJANGO_SETTINGS_MODULE'] = 'email_validator.settings'
os.environ['PYTHON_EGG_CACHE'] = '/tmp'

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

Apache error.log

[Sat Nov 15 12:28:09.374301 2014] [mpm_event:notice] [pid 3827:tid 3074431616] AH00489: Apache/2.4.7 (Ubuntu) mod_wsgi/3.4 Python/2.7.6 configured -- resuming normal operations
[Sat Nov 15 12:28:09.374426 2014] [core:notice] [pid 3827:tid 3074431616] AH00094: Command line: '/usr/sbin/apache2'
[Sat Nov 15 12:32:45.009711 2014] [mpm_event:notice] [pid 3827:tid 3074431616] AH00491: caught SIGTERM, shutting down
[Sat Nov 15 12:32:46.137115 2014] [so:warn] [pid 4297:tid 3074935424] AH01574: module wsgi_module is already loaded, skipping
[Sat Nov 15 12:32:46.142088 2014] [mpm_event:notice] [pid 4298:tid 3074935424] AH00489: Apache/2.4.7 (Ubuntu) mod_wsgi/3.4 Python/2.7.6 configured -- resuming normal operations
[Sat Nov 15 12:32:46.142125 2014] [core:notice] [pid 4298:tid 3074935424] AH00094: Command line: '/usr/sbin/apache2'
[Sat Nov 15 12:42:04.023659 2014] [mpm_event:notice] [pid 4298:tid 3074935424] AH00491: caught SIGTERM, shutting down
[Sat Nov 15 12:42:04.248193 2014] [so:warn] [pid 4409:tid 3074857600] AH01574: module wsgi_module is already loaded, skipping
[Sat Nov 15 12:42:04.252825 2014] [mpm_event:notice] [pid 4410:tid 3074857600] AH00489: Apache/2.4.7 (Ubuntu) mod_wsgi/3.4 Python/2.7.6 configured -- resuming normal operations
[Sat Nov 15 12:42:04.252860 2014] [core:notice] [pid 4410:tid 3074857600] AH00094: Command line: '/usr/sbin/apache2'

当我使用runserver使用此IP地址时,会发生以下情况:

root@tyler-email-validator:/home/email-validator# python manage.py runserver 31.220.49.197:8000
Performing system checks...

System check identified no issues (0 silenced).
November 16, 2014 - 13:19:43
Django version 1.7.1, using settings 'email_validator.settings'
Starting development server at http://31.220.49.197:8000/
Quit the server with CONTROL-C.
Error: That IP address can't be assigned-to.

当我去http://31.220.49.197 Apache并没有为我提供Django应用程序。当我做service apache2 restart时一切顺利。我究竟做错了什么?此配置适用于我的其他应用程序。

0 个答案:

没有答案