Ubuntu (version 16.04 and later) .Net Core WebApi Deployment
Document should be read step by step and every step should be performed by in order the document.
Also you can see this document on: https://docs.tugaycivgin.com/
Introduction:
Install Microsoft .net and .net core packages
Install Nginx
Build and run project
Register Microsoft key and feed:
This only needs to be done once per machine. Open a terminal and run the following commands.
wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.debInstall the .NET Core SDK
Update the products available for installation, then install the .NET Core SDK. In your terminal, run the following commands.
sudo add-apt-repository universe
sudo apt-get update
sudo apt-get install apt-transport-https
sudo apt-get update
sudo apt-get install dotnet-sdk-3.1Install the ASP.NET Core runtime
Update the products available for installation, then install the ASP.NET Core runtime. In your terminal, run the following commands.
Install the .NET Core runtime
Update the products available for installation, then install the .NET Core runtime. In your terminal, run the following commands.
Troubleshoot the package manager
If you receive an error message similar to Unable to locate package {the .NET Core package}, run the following commands.
If that doesn't work, you can run a manual install with the following commands.
Install Nginx
NGINX is open source software for web serving, reverse proxying, caching, load balancing, media streaming, and more. It started out as a web server designed for maximum performance and stability.
Install Nginx
Start Nginx Server
Configure Nginx
To configure Nginx as a reverse proxy to forward requests to your ASP.NET Core app, modify /etc/nginx/sites-available/default. Open it in a text editor, and replace the contents with the following:
*GVim - The Text Editor
Default file is read-only. You have to use a text editor for this. Just go to the directory and use these methods:

Server Status: Check the server status if running
You can see that the server is active

Run Project
Go to directory of your project and use these commands below for the " .dll " file. For example of mine:
On Browser
The server is setup to forward requests made to http://<serveraddress>:80 on to the ASP.NET Core app running on Kestrel at http://127.0.0.1:5000 or http://localhost:5000.However, Nginx isn't set up to manage the Kestrel process. systemd can be used to create a service file to start and monitor the underlying web app. systemd is an init system that provides many powerful features for starting, stopping, and managing processes.

Probable Errors :
"E: Could not get lock /var/lib/dpkg/lock" Error in Ubuntu
Here a similar error you may see:
The first thing you should do is to check if some other program could be running system update or installing a program.
If you are using command line, check if an application like Software Center, Software Updater, Synaptic, Gdebi is running any update/installation. If that’s the case, please wait for the program to finish the running process.
If there is no such application running, please check all the open terminal windows and see if you are running an update or installing a program. If yes, wait for it to finish.
If none of the above is happening, check which other process is running the apt command (package manager for handling software). Use this command:
This will show you the id of the process running apt or apt-get. In the example below, the process id is 7343. You can ignore the last line containing ‘grep –color=auto’.

You can use the process id to terminate it by sending the SIGTERM signal. Replace the <process_id> with the number you got in the output of previous command.
“dpkg: error: dpkg frontend is locked by another process”
If you see the error “dpkg frontend is locked by another process” while running the steps in method 2, you need to one additional step.
First, find out the id of the process that is holding the lock file.
The above command will give you the details of the processes using the lock files. Use the process ID to kill this program:
Now you can remove the lock and reconfigure dpkg:
Uncomplicated Firewall (ufw)
Note: Nginx Full: This profile opens both port 80 (normal, unencrypted web traffic) and port 443 (TLS/SSL encrypted traffic)
We enable the ufw:
We can verify the change with:
Now we can open http://server_domain_or_IP in our browser, and we should be able to see the default Nginx landing page after config the default file in /etc/nginx/sites-available/ directory. You can see it by scrolling up on the page.
Extra:
http://devnot.com/2019/linux-centos-uzerinde-nginx-ile-net-core-uygulamalarini-calistirmak/
Thank You List
Last updated
Was this helpful?