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

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

相关推荐
Lam㊣14 小时前
Ubuntu系统安装Elasticsearch
ubuntu·elasticsearch·jenkins
数智工坊14 小时前
【操作系统-处理器调度】
java·linux·服务器·windows·ubuntu
EndingCoder15 小时前
反射和元数据:高级装饰器用法
linux·运维·前端·ubuntu·typescript
yes_p_m15 小时前
Ubuntu误删/lib64自救指南
linux·运维·ubuntu
数智工坊15 小时前
【操作系统-线程介绍】
linux·算法·ubuntu
周公挚友16 小时前
2026年单服务器 Ubuntu 24.04 无公网离线部署 MongoDB 8.0.17 三节点副本集(主 / 从 / 仲裁)保姆级教程
linux·mongodb·ubuntu
HABuo16 小时前
【linux进程控制(三)】进程程序替换&自己实现一个bash解释器
linux·服务器·c语言·c++·ubuntu·centos·bash
磊磊cpp16 小时前
Ubuntu 22.04 手动安装 XRDP(RDP 远程桌面)教程
linux·运维·ubuntu
等风来不如迎风去16 小时前
【docker】ubuntu空间不够了,删除ragflow
ubuntu·docker·容器
chipsense16 小时前
Ubuntu服务器上为Apache网站安装部署SSL证书详细步骤
linux·ubuntu·ssl