Host a .net 7 app on CloudPanel 2

Services; $ cd /etc/systemd/system $ nano NAapi.service [Unit] Description=NAapi App [Service] WorkingDirectory=/home/deploy/NAapi ExecStart=/usr/bin/dotnet /home/deploy/NAapi/NA.Api.dll --urls "https://localhost:5601" Restart=always # Restart service after 10 seconds if the dotnet service crashes: RestartSec=10 KillSignal=SIGINT SyslogIdentifier=NAapi-app User=root Environment=ASPNETCORE_ENVIRONMENT=Production Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false [Install] That’s it. We can now start the service: $ systemctl start NAapi.service And automatically get it to start on boot: $ systemctl enable NAapi.service deploy script; cd /home nano echo "NAapi Deployment" cd /home/repos/NA.Api/ echo "Sync repo" gh repo sync echo "Stop service" systemctl stop NAapi.service echo "Publishing ..." dotnet publish -c Release -o /home/deploy/NAapi/ echo "Starting service" systemctl start NAapi.service echo "Done!" run script bash config Cloudpanel vhost