2017-09-15 130 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文件對我來說工作正常。希望它可以幫助你!任何關注,請隨時讓我知道。 –

相關問題