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

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

相关推荐
西索斯coding1 小时前
qwen3.8-max 和 minimax-m3 改后端仓库实测复核:补丁通过率与调用成本别急着排冠军
linux·运维·ubuntu·ai
todoitbo13 小时前
在 Ubuntu ARM64 上运行 Q1 V3.0 MuJoCo 模型:加载、步进和单执行器响应
linux·运维·ubuntu·ai·机器人·仿真教程·启元
艸肅1 天前
Docker 国内镜像源配置
linux·ubuntu·docker·1024程序员节
小白今天也很酷1 天前
MCXN947更新板载DAP_Link固件的方法
c语言·python·单片机·ubuntu·excel·1024程序员节
缘友一世2 天前
GLM5.3 CyberSec w4A16本地部署[9]:MTP 调参(num_speculative_tokens 的选择及其负载相关性)
ubuntu·vllm·glm5.3 cybersec
Rabitebla2 天前
【Linux 底层原理】工具篇(一):掌握 Ubuntu apt,让软件安装与管理更简单
linux·笔记·算法·ubuntu
HoneyMoose2 天前
Ubuntu Apache 配置多站点提示 SSL 错误
ubuntu·apache·ssl
qq_377572772 天前
typora install linux ubuntu
linux·ubuntu
我是小灰灰吖2 天前
Ubuntu 22.04 为程序添加桌面启动图标(.desktop 完整实践)
linux·ubuntu
缘友一世3 天前
GLM5.3 CyberSec w4A16本地部署[6]:加载链路与磁盘规划
ubuntu·vllm·glm5.3 cybersec