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

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

相关推荐
人工智能训练14 小时前
从 1.1.3 到 1.13.2!Ubuntu 24.04 上 Dify 升级保姆级教程(零数据丢失 + 一键迁移)
linux·运维·人工智能·windows·ubuntu·dify
吴声子夜歌15 小时前
TypeScript——模块解析
javascript·ubuntu·typescript
cnnews16 小时前
手机通过Termux安装unbuntu,开启SSH
linux·运维·ubuntu·ssh
吴声子夜歌16 小时前
TypeScript——声明合并
linux·ubuntu·typescript
吴声子夜歌19 小时前
TypeScript——命名空间
javascript·ubuntu·typescript
yashuk19 小时前
Ubuntu 系统下安装 Nginx
数据库·nginx·ubuntu
拾贰_C21 小时前
【Ubuntu | Nvidia 】nvidia 驱动安装
linux·运维·ubuntu
Mr成文1 天前
【Linux/Ubuntu】OpenCode +Oh My OpenAgent安装配置实践
linux·运维·ubuntu
YoungHong19921 天前
Claude Code & 智谱GLM-5.1 环境配置指南 (Windows/macOS/Ubuntu)
windows·ubuntu·macos
超b小哥1 天前
【超详细】Claude Code Ubuntu平台完整部署指南
linux·人工智能·ubuntu·ai·claude code