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

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

相关推荐
爱跑马的程序员2 小时前
Linux 如何查看文件夹的大小(du、df、ls、find)
linux·运维·ubuntu
oMcLin4 小时前
如何在 Ubuntu 22.04 LTS 上部署并优化 Magento 电商平台,提升高并发请求的响应速度与稳定性?
linux·运维·ubuntu
想唱rap5 小时前
表的约束条件
linux·数据库·mysql·ubuntu·bash
2501_948195345 小时前
RN for OpenHarmony英雄联盟助手App实战:设置实现
linux·ubuntu
陈让然7 小时前
WSL2 ubuntu18.04扩容
linux·运维·ubuntu
PoppyBu7 小时前
ubuntu20.04安装amule
linux·ubuntu
HIT_Weston7 小时前
94、【Ubuntu】【Hugo】搭建私人博客:面包屑(二)
linux·运维·ubuntu
babytiger9 小时前
scrcpy 编译在ubuntu2404 和UOS上
ubuntu·uos·scrcpy
bedynamic11 小时前
Ubuntu虚拟机磁盘空间不足解决方案
linux·ubuntu
oMcLin11 小时前
如何在Ubuntu 20.04上部署并优化Redis缓存集群,提升大规模电商网站的页面加载速度与缓存效率?
redis·ubuntu·缓存