簡體   English   中英

ASP .NET Core-Linux Nginx ASPNETCORE_ENVIROMENT錯誤

[英]ASP .NET Core - Linux nginx ASPNETCORE_ENVIROMENT Error

我試圖找出一個星期的錯誤,但仍然找不到錯誤。

我當前正在運行的系統是Linux Ubuntu 16.04

我已經在launchSettings.json中將所有內容設置為生產

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:51754/",
      "sslPort": 0
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Production"
      }
    },
    "FilmerCore": {
      "commandName": "Project",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Production"
      },
      "applicationUrl": "http://localhost:51755"
    }
  }
}

這是我的web.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath="dotnet" arguments=".\FilmerCore.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout">
    <environmentVariables>
        <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Production" />
      </environmentVariables>
    </aspNetCore>
  </system.webServer>

</configuration>
<!--ProjectGuid: 5be3ea4c-66c2-42b0-8583-29c6bf415674-->

我正在使用nginx作為反向代理。 主要配置是這樣

[Unit]
    Description=Filmer - .NET movie platform

    [Service]
    WorkingDirectory=/var/aspnetcore/filmer
    ExecStart=/usr/bin/dotnet /var/aspnetcore/filmer/FilmerCore.dll
    Restart=always
    RestartSec=10                                          # Restart service after 10 seconds if dotnet service crashes
    SyslogIdentifier=filmer
    User=www-data
    Environment=ASPNETCORE_ENVIRONMENT=Development 

    [Install]
    WantedBy=multi-user.target

顯示的錯誤

當然,這是行不通的,因為您沒有設置環境變量。

  • web.config僅適用於IIS。 nginx無法執行任何操作。
  • launchSettings.json僅用於Visual Studio在按F5鍵時啟動項目。

您必須查看ngnix文檔,以了解如何在shell中設置環境變量或設置全局變量(這對服務器上的所有應用程序均有效),例如export ASPNETCORE_ENVIRONMENT=Development

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM