Installing Mono into Amazon Linux

This is a cross-posting of Installing Mono into Amazon Linux at Kloud.

There are a couple of ways to run C# applications on Linux operating systems. Before .NET Core, Mono used to be the only way for C# applications running on Linux machine. Each Linux distro has a different method to install Mono. In this post, we’ll walk through how to install Mono on Amazon Linux.

NOTE: Amazon Linux 2016.03.1 was used for this post.

According to the official document, we can follow the CentOS way. However, when we follow the instruction, we’ll get the following error like:

This can be sorted out by following the steps below:

https://gist.github.com/justinyoo/fea4924afbe9b0bf06808a1861a8abb4

First of all, take the root privilege by running the sudo su command. This MUST be returned after the installation to avoid further security breach. Taking the root permissions is not necessary. Instead, we MUST use sudo command every time we need to install something onto Amazon Linux.

Download the RPM package by executing the wget command, then install it. Once we complete installing the missing package, then follow the official document again to set up yum.

https://gist.github.com/justinyoo/6c25161d882ea234a6234d69d93c8877

If necessary, the following commands can help refresh cache.

https://gist.github.com/justinyoo/aea2ec3152fef557359372ae088a69c6

Now, we’re ready for Mono installation. Try the following command for it.

https://gist.github.com/justinyoo/8d37336332a177b156598fd13b4be216

All downloaded files for missing dependencies are no longer necessary. So delete them.

https://gist.github.com/justinyoo/ba241f69845a2b6fb14e7004a5b7fb61

Mono installation completed! Now exit from the root privilege.

https://gist.github.com/justinyoo/5ca61677101e90c468c293b5c86eb0a8

Try a demo code to confirm if Mono has been properly installed. A sample demo code can be found from the official document. If everything is fine, we’ll be able to see the following result:

We’ve installed Mono onto Amazon Linux. As it’s a variation of CentOS/RHEL, it should be as easy as what the document says. However, some missing dependencies need to be installed beforehand. In the next post, we’re going to install .NET Core RC1 and RC2 onto Amazon Linux.