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

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

相关推荐
十日十行13 小时前
修复root用户登录的浏览器无法跳转vscode问题
ubuntu
烧饼Fighting17 小时前
Ubuntu24.04换源和解决物理机无法复制粘贴到虚拟机问题
ubuntu
The️19 小时前
Linux驱动开发之Makefile
linux·驱动开发·mcu·ubuntu
yunianshu20 小时前
Ubuntu 24.04 双系统安装(不使用 U 盘,亲测有效)
linux·运维·ubuntu
ZaneAI21 小时前
🚀 古董笔记本变废为宝:安装 OpenClaw + MiniMax,打造 24 小时在线 AI 助理
ubuntu·agent
xin_yao_xin2 天前
查询端口占用小脚本(ubuntu)
linux·运维·ubuntu
wangjialelele2 天前
Linux信号处理、中断、与页表映射
linux·运维·ubuntu·centos·信号处理·gnu
非自律懒癌患者2 天前
Ubuntu 浏览器建立安全连接失败
linux·运维·ubuntu
HIT_Weston2 天前
129、【Ubuntu】【Hugo】首页板块配置(一)
linux·运维·ubuntu
YYYing.2 天前
【Linux/C++文件篇(一) 】标准I/O与文件I/O基础 :一文掌握文件操作的核心
linux·运维·c语言·c++·ubuntu·centos