我尝试按照 https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-nginx?view=aspnetcore-2.1&tabs=aspnetcore2x 将 ASP.NET Core 2 网站部署到 Ubuntu .
但是,它抛出一个异常:
Failed at step CHDIR spawning "/usr/bin/dotnet": No such file or directory from the file
错误来自这个文件
[Unit]
Description=Example .NET Web API App running on Ubuntu
[Service]
WorkingDirectory=/var/aspnetcore/hellomvc
ExecStart=/usr/bin/dotnet /var/aspnetcore/hellomvc/hellomvc.dll
Restart=always
RestartSec=10 # Restart service after 10 seconds if dotnet service crashes
SyslogIdentifier=dotnet-example
User=www-data
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
[Install]
WantedBy=multi-user.target
但是/usr/bin/dotnet这个命令是存在的,我运行的时候没问题
/usr/bin/dotnet /var/aspnetcore/hellomvc/hellomvc.dll
我用谷歌搜索了一下,但我找到的最佳答案表明它与用户 www-data 有关。我仍然无法弄清楚出了什么问题。任何帮助将不胜感激。
最佳答案
查看WorkingDirectory路径,直接cd到路径。 就我而言,缺少 WorkingDirectory 路径文件夹,当我手动创建它时它开始工作。
希望对您有所帮助。
关于linux - 在步骤 CHDIR 生成 "/usr/bin/dotnet": No such file or directory 时失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50166985/