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

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

相关推荐
Chasing Aurora8 分钟前
Python连接云端Linux服务器进行远程 (后端开发/深度学习)时候的注意事项
linux·开发语言·python·ubuntu·ai编程
w***375119 分钟前
在 Ubuntu 22.04 上安装和配置 Nginx 的完整指南
linux·nginx·ubuntu
渣渣盟33 分钟前
Zookeeper分布式协调服务全解析
分布式·zookeeper·debian
在天愿作比翼鸟在地愿为连理枝2 小时前
UTM+Ubuntu配置MPICH并行环境
linux·运维·ubuntu
荟K2 小时前
Trae连接终端ubuntu电脑
ubuntu·trae
i***58672 小时前
【MySQL数据库】Ubuntu下的mysql
数据库·mysql·ubuntu
The_cute_cat4 小时前
Ubuntu指令的初步学习
linux·运维·ubuntu
太空的旅行者4 小时前
wsl2如何继承Windows网络代理
深度学习·ubuntu
r***86985 小时前
在 Ubuntu 上安装 MySQL 的详细指南
mysql·ubuntu·adb
金斗潼关6 小时前
Ubuntu搭建Vulhub漏洞靶场进行xstream的CVE-2021-21351漏洞利用
linux·ubuntu·java反序列化漏洞检测