2017-09-15 133 views
1

我之前发布过,但没有收到答案。 我有一个在VS2017开发的Django网络应用程序。我已经发布它,但得到一个服务器错误。你能告诉我需要如何配置我的web.config文件,以便它的工作?目前,它是:如何在Azure上部署Django应用程序?

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <appSettings> 
    <add key="PYTHONPATH" value="D:\home\site\wwwroot"/> 
    <add key="WSGI_HANDLER" value="app.wsgi_app"/> 
    <add key="WSGI_LOG" value="D:\home\LogFiles\wfastcgi.log"/> 
    </appSettings> 
    <system.webServer> 
    <handlers> 
     <add name="PythonHandler" path="*" verb="*" modules="FastCgiModule" scriptProcessor="D:\home\Python361x64\python.exe|D:\home\Python361x64\wfastcgi.py" resourceType="Unspecified" requireAccess="Script"/> 
    </handlers> 
    </system.webServer> 
</configuration> 

但我得到一个服务器错误和Python的日志文件中说:

d:\家\ Python361x64 \ python.exe:无法打开文件“d:\家\网站\ wwwroot \ runserver.py':[Errno 2]没有这样的文件或目录

我将不胜感激任何帮助。

+0

我终于设法部署我的应用了!如果您有类似的问题,请确保使用您的应用名称更新WSGI_HANDLER:“MYAPPNAME.wsgi.application”。然后,您需要的另一件事是将您的url添加到Django的settings.py文件中的ALLOWED_HOSTS。这个css文件目前工作,所以仍然需要弄清楚这个。 –

+0

嗨,Lukas.Any进度?我的答案对你有帮助吗? –

回答

0

您需要将static files url configuration添加到web.config文件上KUDU提到here

我试图将我自己的Django项目部署到天蓝色,并使用您的web.config文件,它运行良好。

你可以参考web.config配置如下:

<configuration> 
    <appSettings> 
    <add key="WSGI_HANDLER" value="DjangoWebProject1.wsgi.application"/> 
    <add key="PYTHONPATH" value="D:\home\site\wwwroot"/> 
    <add key="WSGI_LOG" value="D:\home\LogFiles\wfastcgi.log"/> 
    </appSettings> 
    <system.webServer> 
    <handlers> 
     <add name="PythonHandler" path="handler.fcgi" verb="*" modules="FastCgiModule" scriptProcessor="D:\home\python362x86\python.exe|D:\home\python362x86\wfastcgi.py" resourceType="Unspecified" requireAccess="Script"/> 
    </handlers> 
    <rewrite> 
     <rules> 
     <rule name="Static Files" stopProcessing="true"> 
      <conditions> 
      <add input="true" pattern="false" /> 
      </conditions> 
     </rule> 
     <rule name="Configure Python" stopProcessing="true"> 
      <match url="(.*)" ignoreCase="false" /> 
      <conditions> 
      <add input="{REQUEST_URI}" pattern="^/static/.*" ignoreCase="true" negate="true" /> 
      </conditions> 
      <action type="Rewrite" url="handler.fcgi/{R:1}" appendQueryString="true" /> 
     </rule> 
     </rules> 
    </rewrite> 
    </system.webServer> 
</configuration> 

path属性的确定值

<add name="PythonHandler" path="handler.fcgi" verb="*" modules="FastCgiModule" scriptProcessor="D:\home\python362x86\python.exe|D:\home\python362x86\wfastcgi.py" resourceType="Unspecified" requireAccess="Script"/>

url属性值相同

<action type="Rewrite" url="handler.fcgi/{R:1}" appendQueryString="true" /> 
+0

@A。Lukas任何进度? –

+0

Jay,谢谢你的回答。当我在发布我的应用程序之前在Django中将调试模式更改为FALSE时,静态文件无法继续工作,这让我更加困惑,所以我没有甚至知道我的失败尝试是因为这个调试设置还是web.config文件中的错误设置,但我会尽量给你解决方案,并会告诉你它是否工作,再次感谢你的时间! –

+0

T他web.config文件对我来说工作正常。希望它可以帮助你!任何关注,请随时让我知道。 –

相关问题