【问题标题】:Configure Python 3.4 and Django on Windows Azure在 Windows Azure 上配置 Python 3.4 和 Django
【发布时间】:2014-06-30 19:43:23
【问题描述】:

我有一个 Windows Azure 网站,在管理控制台中安装了 Python 3.4。这是 web.config:

<configuration>
<appSettings>
    <add key="pythonpath" value="D:\home\site\wwwroot\mysite;D:\home\site\wwwroot\site-packages" />
    <add key="WSGI_HANDLER" value="django.core.handlers.wsgi.WSGIHandler()" />
    <add key="DJANGO_SETTINGS_MODULE" value="core.settings" />   
</appSettings>
<system.webServer>
    <handlers>
        <add name="Python_FastCGI"
            path="handler.fcgi"
            verb="*"
            modules="FastCgiModule"
            scriptProcessor="D:\Python34\python.exe|D:\Python34\Scripts\wfastcgi.py"
            resourceType="Either"
            requireAccess="Script" />
    </handlers>
    <rewrite>
        <rules>
            <rule name="Django Application" stopProcessing="true">
                <match url="(.*)" ignoreCase="false" />
                <conditions>
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                </conditions>
                <action type="Rewrite" url="handler.fcgi/{R:1}" appendQueryString="false" />
            </rule>
        </rules>
    </rewrite>
</system.webServer>

当 fastCGI 配置的 scriptProcessor 属性设置为使用 d:\Python27 时一切正常,但它不适用于 d:\Python34。我已经使用 python 2.7 来验证文件 D:\Python34\python.exe 和 D:\Python34\Scripts\wfastcgi.py 确实存在于服务器上。

编辑:

为了澄清,服务器返回

The page cannot be displayed because an internal server error has occurred.

检查详细日志时,它会显示一条通用的 500 内部服务器错误消息,指向 FastCgiModule。

【问题讨论】:

  • 询问如何在 Azure 上运行 Django 就像询问如何在骑独轮车时烤出美味的蛋糕。当然,它是可以做到的,而且在你做的时候它可能看起来很酷,但你真的想日复一日地做吗?可悲的事实是,Windows 上的 Django(因此是 azure)是二等公民。
  • @drz 你能在 azure 中运行 python34,因为我在使用 python27 运行良好时遇到了同样的问题
  • 我从来没有让它工作,但几天后我放弃了。也许有人应该开始赏金。

标签: python django azure


【解决方案1】:

您的 web.config 看起来不错。 (但您可能希望启用 appendQueryString="true")。

在 azure 门户中启用日志记录,并在您的 django 项目中临时启用 DEBUG=True。前往 D:\home\LogFiles\ 查看通用 500 消息背后的内容。

您收到通用 500 错误表明您正在运行 django。您还可以在 https://.scm.azurewebsites.net 进程资源管理器中查看 python 进程是否正在运行。

【讨论】:

    猜你喜欢
    • 2016-03-07
    • 2014-06-11
    • 1970-01-01
    • 2014-08-08
    • 2014-07-30
    • 2016-09-02
    • 1970-01-01
    • 1970-01-01
    • 2011-06-17
    相关资源
    最近更新 更多