Debian 安装旧版本.NET

160次阅读
没有评论

先到这里在 Linux 上不使用包管理器的情况下安装 .NET – .NET | Microsoft Learn找到在 Linux 上不使用包管理器的情况下安装 .NET – .NET | Microsoft Learn,看看有没有你需要的版本,如果没有点击这里:.NET 下载(Linux、macOS 和 Windows) (microsoft.com),然后找到你需要的版本,比方v3.1版本:下载 .NET Core 3.1 (Linux、macOS 和 Windows) (microsoft.com), 然后在”二进制文件“根据实际情况下载,我这里选择的是Linux x64:下载 .NET Core 3.1 SDK (v3.1.426) – Linux x64 Binaries (microsoft.com),点击进去就会自动下载二进制了文件了。下载完之后,还需要安装的,执行:

mkdir -p $HOME/dotnet && tar zxf dotnet-sdk-3.1.426-linux-x64.tar.gz -C $HOME/dotnet
export DOTNET_ROOT=$HOME/dotnet
export PATH=$PATH:$HOME/dotnet

另外还需要将可执行文件命令添加到环境变量。

前面的命令只会使 .NET SDK 命令可用于运行它的终端会话。

可以编辑 shell 配置文件来永久添加命令。存在多个不同的 shell 可用于 Linux,并且每个 shell 都有不同的配置文件。例如:

  • Bash Shell: ~/.bash_profile, ~/.bashrc
  • Korn Shell: ~/.kshrc or .profile
  • Z Shell: ~/.zshrc or .zprofile

编辑 shell 的相应源文件,并将 :$HOME/dotnet 添加到现有 PATH 语句的末尾。如果不包含 PATH 语句,则使用 export PATH=$PATH:$HOME/dotnet 添加一个新行。

此外,将 export DOTNET_ROOT=$HOME/dotnet 添加到文件末尾。

注意:即使添加到环境变量,在使用宝塔上的Supervisor守护进程执行命令时候还是可能会遇到找到不该命令的报错:

2024-06-14 16:26:30,156 INFO spawnerr: can't find command 'dotnet'
2024-06-14 16:26:31,157 INFO spawnerr: can't find command 'dotnet'
2024-06-14 16:26:33,159 INFO spawnerr: can't find command 'dotnet'
2024-06-14 16:26:36,244 INFO spawnerr: can't find command 'dotnet'
2024-06-14 16:26:36,244 INFO gave up: FrontPay_00 entered FATAL state, too many start retries too quickly

如果报了该错误,使用绝对路径即可解决该问题。

[program:FrontPay]
command=/root/dotnet/dotnet FrontPay.dll
directory=/www/wwwroot/www.example.com/
autorestart=true
startsecs=3
startretries=3
stdout_logfile=/www/server/panel/plugin/supervisor/log/FrontPay.out.log
stderr_logfile=/www/server/panel/plugin/supervisor/log/FrontPay.err.log
stdout_logfile_maxbytes=2MB
stderr_logfile_maxbytes=2MB
user=root
priority=999
numprocs=1
process_name=%(program_name)s_%(process_num)02d

另外,Supervisor有两个日志:一个被守护进程的执行日志,另外一个即是Supervisor进程守护管理器的日志。

正文完
 0
wujingquan
版权声明:本站原创文章,由 wujingquan 于2024-06-14发表,共计1803字。
转载说明:Unless otherwise specified, all articles are published by cc-4.0 protocol. Please indicate the source of reprint.
评论(没有评论)