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

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

相关推荐
dust_and_stars1 小时前
Ubuntu 24.04 安装配置 vscode-server
前端·ubuntu·eureka
只想恰口饭20 小时前
程序人生-Hello’s P2P
linux·c语言·ubuntu
hoperest20 小时前
程序人生-Hello‘s P2P
linux·c语言·程序人生·ubuntu
quixoticalYan20 小时前
哈工大计算机系统大作业报告-程序人生-Hello’s P2P
linux·windows·程序人生·ubuntu·课程设计
2401_8883135020 小时前
【程序人生-Hello’s P2P】
计算机网络·ubuntu
RK_Dangerous1 天前
第一次使用Docker(Ubuntu)
ubuntu·docker·容器
一文解千机2 天前
wine 优化配置及显卡加速,完美运行Electron 编译的程序(新榜小豆芽、作家助手、小V猫等)
linux·ubuntu·electron·wine·wine优化配置·wine显卡加速·wine大型游戏
coding随想2 天前
ESM + TypeScript:零配置实现类型安全的现代开发
安全·ubuntu·typescript
能源革命2 天前
Ubuntu_24.04 安装OpenClaw教程
linux·ubuntu
laocui12 天前
树莓派Ubuntu系统安装openclow(豆包+QQ机器人)
linux·运维·ubuntu