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

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

相关推荐
生活很暖很治愈3 小时前
Linux——基础IO&软硬链接
linux·ubuntu
Roc.Chang4 小时前
Ubuntu 下 VLC 无法启动(Segmentation fault)终极解决方案
linux·ubuntu·vlc·媒体播放
Anesthesia丶4 小时前
Ubuntu20.04 升级 Ubuntu24.04 LTS
ubuntu
符哥20087 小时前
Ubuntu 常用指令集大全(附实操实例)
数据库·ubuntu·postgresql
陌上花开缓缓归以8 小时前
linux mtd-utils使用源码分析(ubuntu测试版)
linux·arm开发·ubuntu
不爱缺氧i10 小时前
ubuntu离线安装mariadb
linux·ubuntu·mariadb
yyy的学习记录12 小时前
Ubuntu下urdf模型转换成proto模型
linux·运维·ubuntu
xixingzhe212 小时前
ubuntu安装gitlab
linux·ubuntu·gitlab
无风听海12 小时前
.NET10之ASP.NET Core的Filter管线
java·asp.net·.net
William_cl12 小时前
ASP.NET路由长度约束精讲:[HttpGet (“{name:minlength (3)}“)] 字符长度限制吃透,附避坑指南 + 实战代码
后端·asp.net