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