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

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

相关推荐
嵌入式学习和实践1 天前
虚拟机 Ubuntu 磁盘扩容完全指南:从原理到实践,一步到位
linux·ubuntu·磁盘扩容
波波0071 天前
ASP.NET Core 健康检查实战:不只是一个 /health 接口
后端·asp.net
木心术11 天前
TypeScript实战进阶:从基础类型到高级类型编程
javascript·ubuntu·typescript
sheeta19981 天前
TypeScript references 配置与 emit 要求详解
javascript·ubuntu·typescript
ancktion2 天前
ubuntu多gcc版本切换
linux·运维·ubuntu
贵沫末2 天前
Claude Code使用
ubuntu
csdn_aspnet2 天前
了解 ASP.NET Core 中的防伪技术
后端·asp.net·csrf·.net core
叫我黎大侠2 天前
.NET 实战:调用千问视觉模型实现 OCR(车票识别完整教程)
阿里云·ai·c#·ocr·asp.net·.net·.netcore
DeepHacking2 天前
Ubuntu 22.04 安装 Allow Locked Remote Desktop 扩展:解决锁屏后 mstsc 无法连接的问题
linux·运维·ubuntu
成为你的宁宁2 天前
【apt update突然报错Temporary failure resolving ‘cn.archive.ubuntu.com‘】
linux·运维·ubuntu