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

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

相关推荐
liuccn15 分钟前
Ubuntu 22.04 离线升级 OpenSSH 到 9.8p1
linux·ubuntu·github
Mr. Cao code28 分钟前
实战:Docker构建Haproxy负载均衡镜像
linux·运维·ubuntu·docker·容器·负载均衡
巴渝小禹9 小时前
【Ubuntu】虚拟机 Ubuntu 挂载 宿主机 Windows文件夹
linux·ubuntu
biubiubiu070620 小时前
Ubuntu学习笔记
笔记·学习·ubuntu
Eternal-Student1 天前
【ubuntu】在Linux系统上安装Microsoft Edge浏览器
linux·ubuntu·microsoft
肩上风骋1 天前
ubuntu系统使用ifconfig查询网络IP的时候,只能查到本地回环地址,无其他网络接口IP
网络·ubuntu·只能查到本地回环地址
星际工程师1 天前
Windows10安装配置wsl+Ubuntu20.04环境
ubuntu
奔跑吧 android1 天前
【Docker】【2.docker 安装 ubuntu 桌面版】
ubuntu·docker·容器
人工智能的苟富贵1 天前
Rust 异步编程实践:用 Tokio 实现一个迷你 HTTP 服务
ubuntu·http·rust
爱尔兰的楠小楠2 天前
Windows上使用WSL2创建Ubuntu系统,实现无缝高效开发的体验
linux·windows·ubuntu