Jul 8, 2024
Recap of the first three videos:
This video focuses on deploying .NET Core applications to Linux, similar to Windows deployments.
localhost:5024/logs/readall
.NET
command
dotnet webapplication.dll
Install .NET SDK on Ubuntu
lsb_release -a
wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get update; \
apt-get install -y apt-transport-https && \
apt-get update && \
apt-get install -y dotnet-sdk-6.0
dotnet --info
Copy Application to Ubuntu
scp -r publish_folder user@hostname:/var/www/webapi
Run the .NET Application on Ubuntu
cd /var/www/webapi
dotnet webapplication.dll
ifconfig
for IP addresssudo ufw allow 5024/tcp
sudo ufw enable
/etc/systemd/system/webapi.service
):
[Unit]
Description=.NET Web API
[Service]
WorkingDirectory=/var/www/webapi
ExecStart=/usr/bin/dotnet /var/www/webapi/webapplication.dll
Restart=always
RestartSec=10
SyslogIdentifier=dotnet-webapi
User=www-data
Environment=ASPNETCORE_ENVIRONMENT=Production
[Install]
WantedBy=multi-user.target
sudo systemctl enable webapi.service
sudo systemctl start webapi.service
sudo systemctl status webapi.service
sudo a2enmod proxy proxy_http
/etc/apache2/sites-available/webapi.conf
):
<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass / http://localhost:5024/
ProxyPassReverse / http://localhost:5024/
</VirtualHost>
sudo a2ensite webapi.conf
sudo systemctl restart apache2
sudo apt-get install openssl
sudo a2enmod ssl
sudo systemctl restart apache2
openssl req -new -x509 -days 365 -nodes -out /etc/ssl/certs/apache-selfsigned.crt -keyout /etc/ssl/private/apache-selfsigned.key