1) ubuntu $) sudo bash $) apt-get update $) apt-get install dotnet-sdk-8.0 $) apt-get install dotnet-runtime-8.0 $) apt-get install aspnet-core-runtime-8.0 $) dotnet --info $) apt-get install nginx Copy the Files to the Linux Server Next, we need to copy the deployment files to the Ubuntu server. Before we move the files, let’s create the destination folder on the server and set the permissions so that we can add files to it: $) cd /var/www $) sudo mkdir app $) sudo chmod 777 app Run the App on a Kestrel Web Server In a terminal, navigate to the deployment path and run the app in Kestrel: cd /var/www/app sudo dotnet DeployingToLinuxWithNginx.dll //edit nginx config file $ sudo nano /etc/nginx/sites-avaible/default location / { proxy_pass http://127.0.0.1:5000; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection keep-alive; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } } sudo nginx -t sudo nginx -s reload To create the service, we first need to create the configurations in a systemd unit file. The unit file contains information regarding the unit, which is a service in this case. For services, it should have the .service extension and contain some information about the service. These files are required to be in the /etc/systemd/system directory. Let’s use “nano” to create the unit file and name it kestrel-app.service: [Unit] Description=ASP.NET Core Web App running on Ubuntu [Service] WorkingDirectory=/var/www/app ExecStart=/usr/bin/dotnet /var/www/app/DeployingToLinuxWithNginx.dll Restart=always # Restart service after 10 seconds if the dotnet service crashes: RestartSec=10 KillSignal=SIGINT SyslogIdentifier=dotnet-web-app # This user should exist on the server and have ownership of the deployment directory User=www-data Environment=ASPNETCORE_ENVIRONMENT=Production [Install] WantedBy=multi-user.target After adding the content, save it. Then let’s enable and start the service: sudo systemctl enable kestrel-app.service sudo systemctl start kestrel-app.service