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

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

相关推荐
bugtraq20213 小时前
XiaoMi Mi5(gemini) 刷入Ubuntu Touch 16.04——安卓手机刷入Linux
linux·运维·ubuntu
greenery3 小时前
debian 12 安装 NVIDIA 390驱动记录
debian·nvidia·飞牛
zeandon3 小时前
VMWare安装Debian操作系统
debian
大地爱5 小时前
在Ubuntu 22.04 LTS 上安装 MySQL两种方式:在线方式和离线方式
mysql·ubuntu·adb
丰色木夕5 小时前
Ubuntu+vscode+CGAL6.0库安装入门教程
ubuntu·cgal
zeandon7 小时前
Debian系统终端输入ifconfig报错
debian
csdn_aspnet8 小时前
ASP.NET MVC AJAX 文件上传
ajax·asp.net·mvc
翻滚吧键盘10 小时前
配置终端代理
debian
reset202113 小时前
ubuntu离线安装ollama
linux·ubuntu·ollama
m0_7482487713 小时前
在 Ubuntu 上安装 Nginx 的详细指南
nginx·ubuntu·postgresql