Переместить проект Django 1.11 в wsgi

python django apache mod-wsgi django-wsgi

715 просмотра

1 ответ

Пожалуйста, помогите, я мог найти ошибку. Я использую Django 1.11 и Apache (на Centos)

Вот мой wsgi.py

import os
import sys    
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")
activate_this = os.path.expanduser("/var/project/project_python35_venv/bin/activate_this.py")
execfile(activate_this, dict(__file__=activate_this))
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

мой django.conf (из httpd)

WSGILazyInitialization On
WSGIRestrictEmbedded On
WSGIPassAuthorization On

WSGIDaemonProcess project user=apache group=apache processes=10 threads=10 maximum-requests=10000 python-path=/var/project/project_python35_venv/lib/python3.5/site-packages python-home=/var/project/project_python35_venv/lib/python3.5
#WSGIProcessGroup project
#WSGIApplicationGroup %{GLOBAL}
#WSGIPythonHome /var/project/project_python35_venv/lib/python3.5

<VirtualHost *:80>

<Directory /var/project/project_python35_venv>
    Require all granted
</Directory>

CustomLog /var/log/httpd/project-access.log common
ErrorLog /var/log/httpd/project-error.log

DocumentRoot /var/project/project/project/

WSGIScriptAlias / /var/project/project/project/wsgi.py

Alias /static /var/project/project/project/static/

<Directory /var/project/project/project/static>
    Require all granted
</Directory>

<Directory /var/project/project>
    <Files wsgi.py>
        Require all granted
    </Files>
</Directory>

</VirtualHost>

Я пытаюсь все случаи, но все еще получил эту ошибку в моем журнале httpd:

ImportError: нет модуля с именем сайта

Спасибо всем за помощь

Автор: Manish Iarhovich Источник Размещён: 19.09.2019 09:32

Ответы (1)


0 плюса

Решение

Попробуй это

WSGI

import os
import sys

PROJECT_DIR = '/var/project'
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")
def execfile(filename):
     globals = dict( __file__ = filename )
     exec( open(filename).read(), globals )

activate_this = os.path.join( PROJECT_DIR, 'project_python35_venv/bin', 'activate_this.py' )
execfile( activate_this )

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

и apache.conf

WSGILazyInitialization On
WSGIRestrictEmbedded On
WSGIPassAuthorization On

WSGIDaemonProcess project python-path=/var/project/project/:/var/project_python35_venv/lib/python3.5/site-packages/
WSGIProcessGroup project

<VirtualHost *:80>

<Directory /var/project/project_python35_venv>
    Require all granted
</Directory>

CustomLog /var/log/httpd/project-access.log common
ErrorLog /var/log/httpd/project-error.log

DocumentRoot /var/project/project/

WSGIScriptAlias / /var/project/project/wsgi.py

Alias /var/project/project/static /var/project/project/static/

<Directory /var/project/project/static>
    Require all granted
</Directory>

<Directory /var/project>
    <Files wsgi.py>
        Require all granted
    </Files>
</Directory>

</VirtualHost>
Автор: Kostia Skrypnyk Размещён: 09.05.2017 06:07
Вопросы из категории :
32x32