Our Thoughts

  • Elegant Software Solutions

.NET Web Apps Served on a Linux Server

Updated: May 29, 2020


If you’re a .NET developer, you’re probably pretty familiar with IIS. But some of us are also big fans of Linux and all the flexibility that it offers, and it doesn’t hurt that using Linux can cut your hosting costs almost in half. Linux isn’t just for PHP and MySql anymore; you can host full .NET MVC applications on your Linux server using your choice of server software.

The two main HTTP servers for Linux are Apache and nginx. Between the two, they serve about half of the websites around the world. I’m going to show you how you can host your .NET applications on them.

MonoDevelop

First I’ll cover how to add the latest MonoDevelop to Linux. MonoDevelop is the generic version of Xamarin Studio, similar to Visual Studio but much less polished. I’m running Linux Mint 18.2, which is based on Ubuntu 16.04, so this should be very similar if you are using any Linux distribution based on Debian. You do not have to have MonoDevelop installed just to host a .NET application, but I’ll cover the steps to install the latest version anyway.

You can just open the Software Manager and search for MonoDevelop and install it directly from there, but you will not get the most recent version that way. They recently changed the way MonoDevelop will be distributed and the binary packages will no longer be made available for direct installation. Instead, they have switched to using FlatPak for distribution. Flatpak is basically a virtualization layer that puts the application in a sandboxed environment. To get the most recent version of MonoDevelop, you must first install FlatPak:

sudo add-apt-repository ppa:alexlarsson/flatpack sudo apt-get update sudo apt-get install flatpak

Now that you have FlatPak installed, you can use it to install the most recent version of MonoDevelop:

flatpack install --user --from https://download.mono-project.com/repo/monodevelop.flatpackref

And to run MonoDevelop, you use:

flatpack run com.xamarin.MonoDevelop

Flatpak also adds the application to your menu under “Programming” for those that prefer to use the GUI instead of the command line.

Apache2

Now let’s talk about Apache. Apache web server has been around since the mid 1990’s, it’s mature, robust, stable, and super configurable. Apache has all sorts of add-ons that are ready to handle any kind of content, including .NET. The basic install is simple and straight forward; you can just use the Software Manager to search for Apache2 and install it from there. You will also want to install the mono library named “libapache2-mod-mono” so your server can handle .NET applications. These are both available in the Software Manager, or you can install them via command line:

sudo apt-get install apache2 libapache2-mod-mono