我尝试在https://docs.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
我用Google搜索了,但我发现的最佳答案表明它与用户www-data有关。我仍然无法弄清楚出了什么问题。任何帮助将不胜感激。
答案 0 :(得分:5)
查找WorkingDirectory路径,将cd直接查找到该路径。 就我而言,WorkingDirectory路径文件夹丢失了,当我手动创建它时,它开始工作。
希望此帮助。
答案 1 :(得分:-1)
安装dotnet核心
count
sudo nano /etc/systemd/system/api.service
l
在创建文件后运行这些命令
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.asc.gpg
sudo mv microsoft.asc.gpg /etc/apt/trusted.gpg.d/
wget -q https://packages.microsoft.com/config/ubuntu/18.04/prod.list
sudo mv prod.list /etc/apt/sources.list.d/microsoft-prod.list
sudo chown root:root /etc/apt/trusted.gpg.d/microsoft.asc.gpg
sudo chown root:root /etc/apt/sources.list.d/microsoft-prod.list
sudo apt-get update
sudo apt-get install apt-transport-https
sudo apt-get install dotnet-sdk-2.1
NB 始终验证文件和文件夹的位置