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

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

相关推荐
鸿蒙开发工程师—阿辉9 小时前
一键多环境构建——用 Hvigor 玩转 HarmonyOS Next
ubuntu·华为·harmonyos
IT运维爱好者15 小时前
Ubuntu 22.04.4操作系统初始化详细配置
linux·运维·服务器·ubuntu
yangshuo128118 小时前
风车邮箱系统详细使用指南:Windows与Ubuntu双平台解析
linux·windows·ubuntu
谢平康19 小时前
ubuntu扩展逻辑卷并调整文件系统大小步骤
linux·运维·ubuntu
PWRJOY19 小时前
在 Ubuntu 24.04 系统上安装和管理 Nginx
linux·nginx·ubuntu
威桑1 天前
解决Ubuntu下使用CLion构建Qt项目时找不到已安装的模块的问题
linux·运维·ubuntu
电商api接口开发2 天前
ASP.NET MVC 入门指南三
后端·asp.net·mvc
[email protected]2 天前
ASP.NET Core自动事务ActionFilter
后端·asp.net·.netcore
Hello.Reader2 天前
Ubuntu 一站式部署 RabbitMQ 4 并“彻底”迁移数据目录的终极实践
ubuntu·rabbitmq·ruby
余渔鱼11232 天前
ASP.NET CORE部署IIS的三种方式
后端·github·asp.net