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

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

相关推荐
森G1 小时前
五、Linux字符设备驱动
linux·arm开发·c++·ubuntu
企鹅侠客2 小时前
Ubuntu本地部署AnythingLLM实现本地文档RAG
linux·运维·ubuntu·llm
森G2 小时前
六、imx6ull驱动实现
linux·c语言·ubuntu
chao1032 小时前
ubuntu下业务运行环境搭建
linux·运维·ubuntu
龙吟游戏3 小时前
Ubuntu 25.10桌面版安装
linux·运维·ubuntu
米优4 小时前
ubuntu设置分辨率
linux·运维·ubuntu
HIT_Weston4 小时前
51、【Ubuntu】【Gitlab】拉出内网 Web 服务:http.server 单/多线程分析(三)
ubuntu·http·gitlab
ayaya_mana5 小时前
Debian 12 上部署 OpenMediaVault 详细配置步骤
linux·运维·debian·nas·存储服务器·omv
MyFreeIT5 小时前
ubuntu manual
linux·运维·ubuntu
w***15316 小时前
【MySQL数据库】Ubuntu下的mysql
数据库·mysql·ubuntu