只是让您知道我是Linux的新手,现在已经尝试了一段时间,以在Linux Ubuntu 18.04上发布ASP.NET Core网站。
我已经在Visual Studio 2017的ASP.NET Core 2.1中开发了一个测试项目,并且试图将其发布在Ubuntu 18.04上。
我已按照本文所述执行以下步骤:
https://blog.todotnet.com/2017/07/publishing-and-running-your-asp-net-core-project-on-linux/
我不想发布文章中描述的测试网站,而是要发布自己的网站。我正在Visual Studio 2017中发布网站。
将网站发布到Linux上的工作目录后,我具有以下文件:
当我在Linux终端“ journalctl -xe”中键入命令时,出现以下错误:
realpath(): Permission denied
System.UnauthorizedAccessException: Access to the path '/var/www/.dotnet' is denied. ---> System.IO.IOException: Permission denied
--- End of inner exception stack trace ---
at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOpt
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
at System.IO.File.Create(String path)
at Microsoft.Extensions.EnvironmentAbstractions.FileWrapper.CreateEmptyFile(String path)
at Microsoft.DotNet.Configurer.FileSentinel.Create()
at Microsoft.DotNet.Configurer.DotnetFirstTimeUseConfigurer.Configure()
at Microsoft.DotNet.Cli.Program.ConfigureDotNetForFirstTimeUse(INuGetCacheSentinel nugetCacheSentinel, IFirstTimeUseNot
at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, ITelemetry telemetryClient)
at Microsoft.DotNet.Cli.Program.Main(String[] args)
tcore.service: Main process exited, code=exited, status=1/FAILURE
tcore.service: Failed with result 'exit-code'.
它告诉我“ /var/www/.dotnet”被拒绝。实际上,这个路径甚至不存在。
我该怎么做才能解决此问题?
奇怪的是,按照本文的步骤进行操作仍然无效。
leo@leo-virtual-machine:/var/www$ dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 2.1.401
Commit: 91b1c13032
Runtime Environment:
OS Name: ubuntu
OS Version: 18.04
OS Platform: Linux
RID: ubuntu.18.04-x64
Base Path: /usr/share/dotnet/sdk/2.1.401/
Host (useful for support):
Version: 2.1.3
Commit: 124038c13e
.NET Core SDKs installed:
2.1.401 [/usr/share/dotnet/sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.3 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.3 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.0.0-preview1-002111-00 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.3 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.3 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
leo@leo-virtual-machine:/var/www$ dotnet --version
2.1.401
是否存在问题,因为我安装了.NET Core运行时的多个版本?