debian ubuntu armbian部署asp.net core 项目 开机自启动

我本地的环境是 rk3399机器,安装armbian系统。

1.安装.net core 组件

cpp 复制代码
sudo apt-get update && \
  sudo apt-get install -y dotnet-sdk-8.0

或者安装运行库,但无法生成编译项目

cpp 复制代码
sudo apt-get update && \
  sudo apt-get install -y aspnetcore-runtime-8.0

2.编译项目,生成dll,上传到服务器中

3.运行项目

dotnet /var/www/aspnetcore/VDLand.dll --urls "http://*:2001" 端口为2001。这时候启动浏览器,访问ip+:+端口就可以看到网页了。

4.设置开机自启动

在/etc/systemd/system/ 中创建文件 vdland.service

c 复制代码
[Unit]
Description=My very first ASP.NET Core applications running on Ubuntu

[Service]
WorkingDirectory=/var/www/aspnetcore
ExecStart=/usr/bin/dotnet /var/www/aspnetcore/VDLand.dll --urls "http://*:2001"
Restart=always
# Restart service after 10 seconds if the dotnet service crashes:
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=myfirstapp-identifier
User=www-data
Environment=ASPNETCORE_ENVIRONMENT=Development
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false

[Install]
WantedBy=multi-user.target

然后运行:

cpp 复制代码
sudo systemctl enable myfirstwebapp.service

这样项目就会开机自启动了,并且遇到错误关闭后也会自动重启。

相关推荐
嵌入式郑工14 小时前
RK3566 LubanCat 开发板 USB Gadget 配置完整复盘
linux·驱动开发·ubuntu
好奇的菜鸟20 小时前
Ubuntu 18.04 启用root账户图形界面登录指南
数据库·ubuntu·postgresql
zbguolei20 小时前
虚拟机安装Ubuntu后无法登录
linux·运维·ubuntu
叠叠乐21 小时前
移动家庭云电脑永不关机实验版本
ubuntu
i建模21 小时前
在 Ubuntu 中为 npm 切换国内镜像源
linux·ubuntu·npm
每天瞎忙的农民工21 小时前
Ubuntu 24 安装npm22
linux·运维·ubuntu·npm
HIT_Weston21 小时前
116、【Ubuntu】【Hugo】首页板块配置:Leaf Bundle
ubuntu·hugo
a41324471 天前
ubuntu 25 安装vllm
linux·服务器·ubuntu·vllm
csdn_aspnet1 天前
ASP.NET Core 中的依赖注入
后端·asp.net·di·.net core
上天_去_做颗惺星 EVE_BLUE2 天前
Docker高效使用指南:从基础到实战模板
开发语言·ubuntu·docker·容器·mac·虚拟环境