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

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

相关推荐
q***765617 小时前
ubuntu 安装 Redis
linux·redis·ubuntu
Tangcan-19 小时前
在Ubuntu 22.04上安装redis
linux·redis·ubuntu
袁袁袁袁满21 小时前
Ubuntu怎么查看系统日志?
linux·运维·服务器·ubuntu
铁甲前沿1 天前
一个月玩转MQTT(篇五:开发自己的MQTT WEB页面)
前端·mqtt·asp.net·mqtt web开发
yuyuyuliang001 天前
Ubuntu 22.04安装PostgreSQL教程
linux·运维·ubuntu·postgresql
njtong1 天前
Ubuntu系统apache2网站的Let‘s Encrypt证书问题
linux·运维·ubuntu
HIT_Weston1 天前
132、【Ubuntu】【Hugo】搜索功能异常(问题解决)(二)
linux·运维·ubuntu
l1t1 天前
在debian 13.1容器中安装使用redrock postgresql
运维·postgresql·debian
xj198603191 天前
Java进阶-在Ubuntu上部署SpringBoot应用
java·spring boot·ubuntu
若谷老师2 天前
21.WSL中部署gnina分子对接程序ds
linux·人工智能·ubuntu·卷积神经网络·gnina·smina