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 小时前
ubuntu添加用户完整命令
linux·运维·ubuntu
horizon727410 小时前
如何迁移 WSL2 虚拟机到其他磁盘
linux·ubuntu
wadesir12 小时前
Debian SSH密钥生成(详细教程:使用ssh-keygen命令配置安全远程登录)
安全·debian·ssh
大连好光景13 小时前
WSL下创建的Ubuntu系统与Windows实现显卡直通
linux·运维·ubuntu
huangjiazhi_13 小时前
Ubuntu 添加服务自启动
linux·运维·ubuntu
GDAL14 小时前
腾讯云ubuntu安装nodejs环境
ubuntu·nodejs·腾讯云
SCBAiotAigc15 小时前
在Ubuntu上使用docker compose安装普通(不支持GPU)的Ollama服务
人工智能·python·ubuntu·ollama
Ancelin安心15 小时前
关于代理的一些网络知识复盘
linux·运维·网络·计算机网络·web安全·ubuntu·网络安全
Norach15 小时前
Ubuntu升级opencv版本至4.9.0
linux·经验分享·opencv·yolo·ubuntu·dnn
linzihahaha16 小时前
vmware-ubuntu 虚拟机共享文件及复制拖动配置
linux·运维·ubuntu