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

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

相关推荐
橘子编程8 分钟前
JavaScript与TypeScript终极指南
javascript·ubuntu·typescript
12345,catch a tiger2 小时前
虚拟机ubuntu安装Vmware Tools
linux·运维·ubuntu
辰风沐阳2 小时前
OpenClaw 安装教程(Ubuntu 24.04 Desktop)
linux·ubuntu
六点的晨曦5 小时前
VMware安装Ubuntu的记录
linux·ubuntu
问简6 小时前
ubuntu 字体相关问题
运维·服务器·ubuntu
沐雪轻挽萤8 小时前
无人系统:Ubuntu 操作系统全景架构与实战工程指南
linux·运维·ubuntu
corpse201010 小时前
VirtualBox 安装ubuntu-25 ,配置SSH工具登录
linux·ubuntu·ssh
YYYing.11 小时前
【Linux/C++网络篇(一) 】网络编程入门:一文搞懂 TCP/UDP 编程模型与 Socket 网络编程
linux·网络·c++·tcp/ip·ubuntu·udp
魔都吴所谓11 小时前
【Ubuntu】22.04安装 CMake 3.24
linux·运维·ubuntu
无风听海11 小时前
.NET10之内置日志配置与使用指南
asp.net·.net