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

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

相关推荐
SilentSamsara18 小时前
SSH 远程管理:密钥登录 + 隧道转发,一次性配置好
linux·运维·服务器·ubuntu·centos·ssh
xuanwenchao1 天前
Mac M1/M2/M3/M4/M5芯片-系统安装Ubuntu
linux·ubuntu·macos
叫我刘同学1 天前
腾讯云 Ubuntu 服务器部署 Hermes Agent 详细安装教程
服务器·ubuntu·腾讯云
fzil0011 天前
让 AI 自己协作 —— 多智能体(Swarm)系统的设计与实现
java·开发语言·人工智能·ubuntu
企鹅的蚂蚁1 天前
Ubuntu 22.04 终端进阶:Terminator 安装与快捷键完全手册
linux·运维·ubuntu
千里马学框架1 天前
Ubuntu 24 搭建aosp源码环境详细笔记
android·linux·ubuntu·framework·安卓·aosp·源码环境
sanzk1 天前
ASTRA PRO相机
ubuntu·ros·3d相机
四禾子1 天前
ubuntu的使用心得体会
linux·运维·ubuntu
学Linux的语莫1 天前
vscode连接linux服务器,linux环境编程开发。
linux·vscode·ubuntu·编辑器
两点王爷1 天前
Ubuntu 机器安装解压软件和ip工具
linux·运维·ubuntu