0

我正在安装 django,

wsgi 的测试没问题,但是当我将默认文件指向 django 测试时,它不起作用,

这是运行良好的测试:

默认: /etc/apache2/sites-available/default

<VirtualHost *:80>
    ServerName www.example.com
    ServerAlias example.com
    ServerAdmin webmaster@example.com
    DocumentRoot /var/www

    <Directory /var/www/documents>
    Order allow,deny
    Allow from all
    </Directory>
    WSGIScriptAlias / /home/ubuntu/djangoProj/micopiloto/application.wsgi
    <Directory /home/ubuntu/djangoProj/mysitio/wsgi_handler.py>
    Order allow,deny
    Allow from all
    </Directory> 
</VirtualHost>

应用程序.wsgi::~/djangoProj/micopiloto

import os 
import sys 

sys.path.append('/srv/www/cucus/application') 
os.environ['PYTHON_EGG_CACHE'] = '/srv/www/cucus/.python-egg' 

def application(environ, 
start_response):

     status = '200 OK'

     output = 'Hello World!MK SS9 tkt kkk'

     response_headers = [('Content-type', 'text/plain'),

                                     ('Content-Length', str(len(output)))]

     start_response(status, response_headers)


     return [output]

但是如果我将默认值更改为指向application_sa.wsgidjango 测试,它就不起作用:(

application_sa.wsgi

import os, sys

sys.path.append('/home/ubuntu/djangoProj/micopiloto') 


os.environ['DJANGO_SETTINGS_MODULE'] = 'micopiloto.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

每次我将 wsgi 更改为测试时,我都会重新启动 apache 服务器,

所以我错过了什么?

多谢!

4

1 回答 1

1

尝试将您的 apache 配置更改为以下内容:

AddHandler wsgi-script .wsgi

WSGISocketPrefix /var/run/wsgi
WSGIRestrictEmbedded On

<VirtualHost *:80>
    ServerName www.mydomain.com

    WSGIDaemonProcess myprocess processes=2 threads=15
    WSGIProcessGroup myprocess

    WSGIScriptAlias / /home/ubuntu/djangoProj/micopiloto/application_sa.wsgi
</VirtualHost>

然后将项目的根文件夹添加到 sys.path 以及 application_sa.wsgi 中:

sys.path.append('/home/ubuntu/djangoProj') 
sys.path.append('/home/ubuntu/djangoProj/micopiloto') 
于 2012-04-08T05:31:08.053 回答