Deploy Angular + ASP.NET Core 2 + Entity Framework + MySQL application on DigitalOcean’s Ubuntu droplet
If you are looking for deploying Angular application on NgInx server + Digital Ocean's Ubuntu droplet, read below article.
In this article we shall see how to deploy an application built using Angular + ASP.NET Core 2 + Entity Framework + MySQL application on Digital Ocean's Ubuntu droplet.
We have the front end web application built using Angular which calls ASP.NET Core 2 REST APIs. ASP.NET Core application reads data from MySQL database using Entity Framework Core framework. We are assuming that development is done and we are ready for deployment.
Build Angular application
First step is to build Angular application in production mode. To do so, run
ng build --prod command. This command shall generate
dist folder with output files.
Serve Angular application from .NET Core
We want to set Angular application to be served as default route of ASP.NET Core application. For that,
- Copy all files from
distfolder and paste in
wwwrootfolder of ASP.NET Core folder.
Configure()method by adding
Publish ASP.NET Core application
Publish your ASP.NET Core application either using Visual Studio “Publish” option or use
Copy paste published website to droplet using FileZilla or any other FTP tool.
Working with Digital Ocean droplet
Once we have copied all build files to droplet, we can connect to our droplet using Putty or any other SSH tool.
Install NgInx server
How To Install Nginx on Ubuntu 16.04 | DigitalOcean
Nginx is one of the most popular web servers in the world and is responsible for hosting some of the largest and…
Setup MySQL database on Ubuntu DigitalOcean
How To Install MySQL on Ubuntu 16.04 | DigitalOcean
MySQL is an open-source database management system, commonly installed as part of the popular LAMP (Linux, Apache…
Import database using command:
mysql -u username -p database_name < file.sql
Install ASP.NET Core SDK
Prerequisites for .NET Core on Linux
In this article This article shows the dependencies needed to develop .NET Core applications on Linux. The supported…
NgInx configuration for ASP.NET Core
/etc/nginx/sites-available/default file and update below configuration:
Make sure below line is commented
#try_files $uri $uri/ =404;
Validated nginx configuration by running command
sudo nginx -t
Reload nginx configuration by running command
sudo nginx -s reload
On droplet, navigate to application output folder and run command
This shall start web server listening on localhost:5000.
We have configured NgInx server to forward all incoming routes on port 80 to localhost:5000.
Go to browser and hit droplet ip-address. You should get your Angular application running and can access ASP.NET Core REST API.
If you encounter any error, check nginx logs folder for troubleshooting.
Hope you enjoyed this article.