简体   繁体   English

在等待本地主机的apache mod_wsgi下部署django

[英]deploy django under apache mod_wsgi waiting for localhost

I am deploying a Django project on Apache. 我正在Apache上部署Django项目。 and after configuration, I open the "localhost" in the browser, and nothing showed up and the status bar just keep saying "Waiting for localhost". 配置完成后,我在浏览器中打开“ localhost”,但没有显示任何内容,状态栏一直显示“ Waiting for localhost”。 Here is some info. 这是一些信息。

Environment: 环境:

OS: ubuntu 
Python: 2.7.3
Django: 1.8.2
Apache: 2.2.21
Django project: /var/www/ocr_service

Apache virtualhost: Apache虚拟主机:

WSGIScriptAlias / /var/www/ocr_service/ocr_service/wsgi.py
WSGIPythonPath /var/www/ocr_service
<VirtualHost *:80>
LogLevel info

ErrorLog /var/www/ocr_service/log/error.log
CustomLog /var/www/ocr_service/log/access.log combined

<Directory /var/www/ocr_service >
    <Files wsgi.py>
    Order deny,allow
    Allow from all
    </Files>
</Directory>
</VirtualHost>

Django.wsgi file: Django.wsgi文件:

import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ocr_service.settings")

application = get_wsgi_application()

I try with a empty django project and it works. 我尝试一个空的django项目,它可以正常工作。 These are what I did, can someone help me to see if somewhere is wrong? 这些是我所做的,有人可以帮助我看看某处是否有问题?

apache2/error log report only the resuming normal operation message custom log report apache2 /错误日志报告仅恢复正常运行消息自定义日志报告

  mod_wsgi (pid=10***, process='',application='127.0.1.1|') loading wsgi script '/var/www/ocr_service/ocr_service/wsgi.py"

Try adding to the Apache configuration file: 尝试添加到Apache配置文件中:

WSGIApplicationGroup %{GLOBAL}

See: 看到:

As the log snippet shows the WSGI file at least being loaded, which would only happen if a request is received, the issue may that you are using third party extension modules for Python that will not work in sub interpreters properly and they deadlock and hang the request. 由于日志片段显示了至少正在加载WSGI文件(仅在收到请求时才会发生),因此问题可能是您使用的Python第三方扩展模块无法在子解释器中正常工作,并且它们死锁并挂起请求。 Setting that directive avoids the problem. 设置该指令可以避免此问题。

Also recommended that you do not use embedded mode as you are, but use daemon mode instead: 还建议您不要按原样使用嵌入式模式,而应使用守护程序模式:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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