python - 在 Windows Azure 上配置 Python 3.4 和 Django

标签 python django azure

我有一个 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。

最佳答案

您的 web.config 看起来没问题。 (但您可能想要启用appendQueryString =“true”)。

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

事实上,您收到通用 500 错误表明您正在运行 django。您还可以在 https://.scm.azurewebsites.net process explorer 中查看 python 进程是否正在运行。

关于python - 在 Windows Azure 上配置 Python 3.4 和 Django,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24497774/

相关文章:

python - 检查项目是否在 ManyToMany 字段中?

Azure APIM 与 Istio 网关集成

c# - 在 Azure Function 中使用相关 ID 进行日志记录

python - 有什么方法可以替换 break 以提前退出 for 循环吗?

python - python是否有一个安全的,用户可编辑的脚本标记,用于像RoR的液体模板?

python - 安装 Python 2.7 和 Python 3.5 后,使用 IDLE 编辑选项不可用。应该做什么?

python - Mongodb 或 Couchdb 与 django 构建类似于顶级编码器的应用程序?

python - 骰子滚轮的第二个 while 循环出现问题

python - 如何在 Django 中使用 MySQL View ?

c# - 将 MemoryStream 保存到 Azure Blob 存储