Install Mono 2.11 from Source on Ubuntu with a Bash Script

NOTE: Ubuntu 12.04 LTS and Badgerports.org are now current w/ 2.10.8.1. This bash script is more useful when installing parallel Mono, when a new version is released and not yet published on badgerports, or if you simply want to compile it yourself from source. I highly recommend trying the latest Ubuntu or Badgerports first.

Updated Sept 11, 2012 – Incremented Mono to 2.11.3 (from 2.11.0).

Install

This script is meant to be a barebones web server install. Feel free to tweak the script and add as many packages as you like to it.

mkdir mono-2.11
cd mono-2.11
wget --no-check-certificate https://github.com/nathanb/iws-snippets/raw/master/mono-install-scripts/ubuntu/install_mono-2.11.sh
chmod 755 install_mono-2.11.sh
./install_mono-2.11.sh

 

There is also a CentOS/Red Hat script in the GitHub repository.

Enjoy!

19 thoughts on “Install Mono 2.11 from Source on Ubuntu with a Bash Script

  1. Thanks for the Centos script…I’m testing the feasibility of running an Asp.Net MVC 4 site with Linux/Mono/MySQL…gonna give it a whirl over the weekend.

  2. For Beginners who don’t know how to get the new Mono 3.0.1 version on Ubuntu 12.04
    (Because i’m a beginner and i’ve been working on this for 3 days before make it work)

    ###############################################################
    ### Getting root access to install and configure Mono 3.0.1 ###
    ###############################################################
    sudo -s
    ***type your root password***

    ##########################
    ### Install vim editor ###
    ##########################
    apt-get install vim

    #######################
    ### Install apache2 ###
    #######################
    apt-get install apache2

    ########################################
    ### Install tools for compiling mono ###
    ########################################
    apt-get install autoconf automake libtool g++ gettext
    apt-get install mono-gmcs<
    apt-get install git

    #######################################################################
    ### Install apache2-threaded-dev (needed for compiling mod_mono)*** ###
    #######################################################################
    apt-get install apache2-threaded-dev

    #####################################################
    #####################################################
    ### We will return to apache2 configuration later ###
    #####################################################
    #####################################################

    ################################################################
    ### Making the structure we need for getting the source code ###
    ################################################################
    cd /opt
    mkdir mono-3.0

    ################################################################
    ### Move into that new folder before getting the source code ###
    ################################################################
    cd /opt/mono-3.0

    ###########################################
    ### Getting the source code from GitHub ###
    ###########################################
    git clone git://github.com/mono/mono.git
    git clone git://github.com/mono/xps.git
    git clone git://github.com/mono/libgdiplus.git
    git clone git://github.com/mono/mod_mono.git

    ##########################
    ### Compile libgdiplus ###
    ##########################
    cd /opt/mono-3.0/libgdiplus
    ./autogen.sh –prefix=/usr (the prefix is very important for Ubuntu 12.04)
    make
    make install

    ####################
    ### Compile mono ###
    ####################
    cd /opt/mono-3.0/mono/
    make clean
    ./autogen.sh –prefix=/usr (the prefix is very important for Ubuntu 12.04)
    make
    make install

    ###################
    ### Compile xsp ###
    ###################
    cd /opt/mono-3.0/xsp
    ./autogen.sh –prefix=/usr (the prefix is very important for Ubuntu 12.04)
    make
    make install

    ########################
    ### Compile mod_mono ###
    ########################
    cd /opt/mono-3.0/mod_mono
    ./autogen.sh –prefix=/usr (the prefix is very important for Ubuntu 12.04)
    make
    make install

    ##################################################################
    ##################################################################
    ### After the installation of mod_mono, the file mod_mono.conf ###
    ### as been added to your apache2 folder(/etc/apache2) ###
    ##################################################################
    ##################################################################

    ###########################
    ###########################
    ### Configuring apache2 ###
    ###########################
    ###########################

    ###########################################################
    ### Configure the default site of apache ### (optional***)
    ###########################################################
    vim /etc/apache2/sites-available/default
    Modify the line "DocumentRoot /var/www" by "DocumentRoot /var/www/YourFolder" (YourFolder is the folder where you publishing your website!)

    #########################################################
    ### Configure the rights to YourFolder ### (optional***)
    #########################################################
    cd /var/www/YourFolder
    sudo chown -R root:www-data .
    sudo chmod -R 774 .
    sudo usermod -a -G www-data

    ###################################################
    ### Adding the mod_mono include in apache2.conf ###
    ###################################################
    vim /etc/apache2/apache2.conf
    Add “Include /etc/apache2/mod_mono.conf” at the end of the file (without quotes!)

    ###########################################################
    ### Adding the pointer to ASP .NET 4.0 in mod_mono.conf ###
    ###########################################################
    vim /etc/apache2/mod_mono.conf
    Add “MonoServerPath /usr/bin/mod-mono-server4″ (without quotes!) under the “If Modules condition”

    ##################################
    ### Restart the apache2 server ###
    ##################################
    /etc/init.d/apache2 restart

  3. Hi I’m trying to configure apache with mod_mono on Debain but ends up with System.Web.Compilation.CompilationException
    : Unhandled Exception:
    Description: Error compiling a resource required to service this request. Review your source file and modify it to fix this error.

    Details: : Unhandled Exception:

    Error origin: Compiler
    Below are the Mono details:
    Mono JIT compiler version 3.0.0 (master-experimental/3f84403 Wed Oct 24 20:38:33 CEST 2012)
    Copyright (C) 2002-2012 Novell, Inc, Xamarin Inc and Contributors. http://www.mono-project.com
    TLS: __thread
    SIGSEGV: altstack
    Notifications: epoll
    Architecture: amd64
    Disabled: none
    Misc: softdebug
    LLVM: supported, not enabled.
    GC: Included Boehm (with typed GC and Parallel Mark)
    any help to the right direction is greatly appreciated.

  4. Further update : I could get the pages work but … the pages are serverd by 2.0 instead of mod-mono-server4.How do I check and fix this?

  5. @KrishnaM
    ###########################################################
    ### Adding the pointer to ASP .NET 4.0 in mod_mono.conf ###
    ###########################################################
    vim /etc/apache2/mod_mono.conf
    Add “MonoServerPath /usr/bin/mod-mono-server4″ (without quotes!) under the “If Modules condition”

    This should correct your problem

  6. I tried running this from 12.10, and ended up with errors:

    make[3]: *** [thread.lo] Error 1
    make[3]: Leaving directory `/root/mono-2.11/build/gtk-sharp-2.12.11/glib/glue’
    make[2]: *** [all-recursive] Error 1
    make[2]: Leaving directory `/root/mono-2.11/build/gtk-sharp-2.12.11/glib’
    make[1]: *** [all-recursive] Error 1
    make[1]: Leaving directory `/root/mono-2.11/build/gtk-sharp-2.12.11′
    make: *** [all] Error 2

    error: #error “Only can be included directly.”

    stuff like that. Any suggestions?

  7. I’m running on Ubuntu 12.04. I was able to install mono 2.11.3 using the script. I have no problems compiling and running c# from the command line, but when I try to install monodevelop 3.0 from git, i get an error from ./config:
    configure: error: You need mono 2.10.9 or newer

    but mono -V gives me this:

    Mono JIT compiler version 2.11.3 (tarball Mon Apr 1 22:54:39 PDT 2013)

    Anyone have any ideas? There are no support links on the mono git pages.

    Thanks,
    Bruce

  8. @Bruce
    It may be as simple as just updating your path initially before invoking monodevelop.

    i.e. (pseudo code)

    export PATH=$PATH:/opt/mono-3.0/bin && monodevelop

  9. Sorry, i tried this on Ubuntu Server 13.03 and get this:

    make[3] : *** [libmonoruntime_la-image.lo] Error 1
    make[3]: Leaving directory ‘/home/*/mono-2.11/build/mono-2.11.3/mono/metadata’
    make[2]: ***[all-recursive] Error 1
    make[2]: Leaaving directory ‘/home/*/mono-2.11/build/mono-2.11.3′
    make: *** [all] Error 2

    any ideas?

  10. Hi @Wesea,

    I’m thinking there might have been another error earlier in that log. Those seem like the output you usually see following an error where it’s bubbling out of the stack. (per se).

    To be honest, I haven’t tested this on 13.04. I’m also curious which version they have packaged with 13.04, because I’m seeing 10.8.1 on LTS 12.04. Curious if 2.11+ might be pre-packaged. It might save you some frustration.

    Try:
    sudo apt-cache show mono-devel and see which version shows up.

  11. So, I ran this. (Thanks btw!) And it seemed to go to completion (said “Done”). However when I run “mono -V” I still see the previous version. Is there something else I have to do to get the system to see the new version?

  12. Yup! That’s what should happen. This uses the Parallel Mono Environments method where it installs to /opt/mono-xx instead of the default paths so you can run multiple versions (the platform version and this custom one) without colliding. So when you run apache,nginx, or CLI apps, you’ll need to setup your environment. Check that article out for info on how to do that. “ls” your /opt directory to see what the actual path is (I don’t recall at the moment for this article). Reference back to that when the mono article talks about installation paths.

    Hope that helps!

    You can /opt/mono-2.11/bin/mono –version to run the one you just built and installed. ;)

  13. Sorry for the response delay. It appears you have the incorrect url for that script. This article is quite old. Checkout github.com/nathanb/iws-snippets instead. Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>