apache+django+mod_wsgi (проблема)

Обсуждение настройки и работы сервисов, резервирования, сетевых настроек и вопросов безопасности ОС.

Модераторы: SLEDopit, Модераторы разделов

vsdfn
Сообщения: 147
ОС: Windows,Linux,BSD

apache+django+mod_wsgi

Сообщение vsdfn »

cat /etc/apache2/vhosts.d/00_default_vhost.conf

Код: Выделить всё

# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

<IfDefine DEFAULT_VHOST>
# see bug #178966 why this is in here

# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 80

# Use name-based virtual hosting.
NameVirtualHost *:80

# When virtual hosts are enabled, the main host defined in the default
# httpd.conf configuration will go away. We redefine it here so that it is
# still available.
#
# If you disable this vhost by removing -D DEFAULT_VHOST from
# /etc/conf.d/apache2, the first defined virtual host elsewhere will be
# the default.
<VirtualHost *:80>
        ServerName localhost
        Include /etc/apache2/vhosts.d/default_vhost.include

        <IfModule mpm_peruser_module>
                ServerEnvironment apache apache
        </IfModule>
</VirtualHost>

<VirtualHost *:80>
        ServerName govno.com
        ServerAlias www.govno.com
        ServerAdmin admin@mysite.com
        DocumentRoot "/home/user/source_project/python/djcode/govno/"
        <Directory  "/>
        Options Indexes FollowSymLinks
        WSGIProcessGroup main
        WSGIApplicationGroup %{GLOBAL}
        AllowOverride All
        Order allow,deny
        Allow from all
        </Directory>
        ScriptAlias / /home/user/source_project/python/djcode/govno/django.wsgi
</VirtualHost>

</IfDefine>

localhost user # apache2 -M |grep wsgi

Код: Выделить всё

apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
Syntax OK
 wsgi_module (shared)

т.е модуль подгружен

cat source_project/python/djcode/govno/django.wsgi

Код: Выделить всё

#-*- coding: utf-8 -*-
import os, sys, site
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
sys.path.insert(0,os.path.dirname(__file__))
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
from django.core.handlers.wsgi import WSGIHandler
application = WSGIHandler()


итог:
localhost user # curl govno.com

Код: Выделить всё

#-*- coding: utf-8 -*-
import os, sys, site
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
sys.path.insert(0,os.path.dirname(__file__))
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
from django.core.handlers.wsgi import WSGIHandler
application = WSGIHandler()


Т.е апач не сопоставляет wsgi и не передает его обработчику, а тупо при запросе / выдает как текстовичек django.wsgi=)
Спасибо сказали: