我本地的环境是 rk3399机器,安装armbian系统。
1.安装 core 组件
sudo apt-get update &&
sudo apt-get install -y dotnet-sdk-8.0
或者安装运行库,但无法生成编译项目
sudo apt-get update &&
sudo apt-get install -y aspnetcore-runtime-8.0
2.编译项目,生成dll,上传到服务器中
3.运行项目
dotnet /var/www/aspnetcore/VDLand.dll --urls “*:2001” 端口为2001。这时候启动浏览器,访问ip+:+端口就可以看到网页了。
4.设置开机自启动
在/etc/systemd/system/ 中创建文件 vdland.service
[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 "*: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
然后运行:
sudo systemctl enable myfirstwebapp.service
这样项目就会开机自启动了,并且遇到错误关闭后也会自动重启。
本文发布于:2025-04-07 03:14:00,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/1743966943584818.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |