My Adventures Installing mono 2.0 on CentOS 4 to work with apache via mod_mono

Apparently the good folks over at the mono project decided to discontinue binary packages for the Red Hat line of linux distributions.  It’s a shame in a way, there are a lot of those installation out there, so it would be nice to keep things updated through yum or apt-install or rhupdate, etc..

On the up side, installing from source has never been easier.  In the past I have went through many hours of trying to get the right versions of different libraries that were needed.  With the official release of 2.0 it seems much better.  I thought I would share the steps that I went through.

Disclaimer: This worked on a fairly fresh install of CentOS 4.7.  I have not tried it on 5.x, nor on any other flavor of linux (SUSE, Ubuntu, etc..) so your mileage may vary.

At the time of the install (and this writing) the current mono stable version is 2.0.1 so all references will be to that version.  Here are the steps that I went through.


Always be prepared – Boy Scouts motto…

In rooting around the web I did find a few helpful pointers.  First, make sure you have gcc installed.  Now this is one of those duh pieces of information, but in the fairness of completeness I thought I would mention it. (Note: If you do not have gcc or bison, install them! Credit The_Assimilator’s comment)

# yum install gcc-c++
# yum install bison
Next I installed the httpd-devel package.  I had read (will find the link later) that it helps some of the installation down the line.  In my case I just use yum to install it. (Note:  httpd-devel package is required by the mod_mono compile if apxs (Apache Extension Tool) is not on your machine. credit to The_Assimilator’s comment)
yum install httpd-devel

You may also require the glib-2.0 libraries (thanks to Michael Walsh for that bit).  If you receive the error “Package glib-2.0 was not found in the pkg-config search path” you can install it via yum as well.

yum install glib2-devel

The Main Dance

Next comes the meat of the installation.  First, I downloaded the necessary source packages.  I simply used wget to snag the core mono package, xsp (mono web server) and mod_mono (apache integration).


Next we install the mono core

tar -vxjf mono-2.0.1.tar.bz2
cd mono-2.0.1
make install
cd ..

Next comes xsp

tar -vxjf
cd xsp-2.0
make install
cd ..

At this point I recevied an error (I believe it was in the make process) that the compiler could not find the file dotnet.pc.  I found that it was indeed on my system so I simply had to export the path and then finsih the compile.

export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
make install

Note: Make sure the file dotnet.pc is in that location.  If not, adjust the path above.

Finally we install mod_mono

tar -vxjf mod_mono-2.0.tar.bz2
cd mod_mono-2.0
make install

There, easy huh?


You may want to verify a few thigns to make sure the configuration is ready to rock.  In my case, I am keeping the mono configuration in a separate file for sanity sake.  You can do that or put it all in your httpd.conf, it’s up to you.

<IfModule !mod_mono.c>
    LoadModule mono_module /usr/lib/httpd/modules/
    AddType application/x-asp-net .aspx
    AddType application/x-asp-net .asmx
    AddType application/x-asp-net .ashx
    AddType application/x-asp-net .asax
    AddType application/x-asp-net .ascx
    AddType application/x-asp-net .soap
    AddType application/x-asp-net .rem
    AddType application/x-asp-net .axd
    AddType application/x-asp-net .cs
    AddType application/x-asp-net .config
    AddType application/x-asp-net .Config
    AddType application/x-asp-net .dll
    DirectoryIndex index.aspx
    DirectoryIndex Default.aspx
    DirectoryIndex default.aspx
That was it.  I hope that helps!

17 thoughts on “My Adventures Installing mono 2.0 on CentOS 4 to work with apache via mod_mono

  1. Hey, that’s a really useful tutorial. I’ve been bitten by Novell not doing Mono 2.0 RHEL packages anymore too.

    Just some notes that may help people if they get stuck:

    I assume you want the httpd-devel package (instead of httpd-devl)

    Mono requires at least glib-2.0 to compile and not everyone will have that. If you hit an error like “Package glib-2.0 was not found in the pkg-config search path” then you can get it by running:
    yum install glib2-devel

    after yum installing mod_mono it may put a line in your httpd.conf pointing to a nonexistant conf like “Include /conf.d/mod_mono.conf” which doesn’t exist on my machine so watch out for that too

  2. Thanks Michael. Yes, a misspelling on the httpd-devel. 😀 I’ve corrected that in the post.

    I did not run into the glib-2.0 problem, thanks for that tip. I’ve added that as well.

  3. Thanks for the tutorial!
    I was able to compile from source using CentOS 5.2. The OS came with the correct glib package, but I still had export the package path to dotnet.pc.

    I was also able to successfully setup the MonoApplications using .NET 2.0 libraries. There’s a few tricks there, especially for applications that already run on IIS.

    When adding the MonoServerPath to httpd.conf, I had to use

    MonoServerPath /usr/local/bin/mod-mono-server2

    You just need to make sure you point it to the right path. All of the documentation I read had the mono server files in different places.

    Also, if you’re Web.Config file references other files (like we do with log4net), you’ll need to change the paths to those files to use forward slashes, ‘/’, for linux to find them.
    You’ll also need to make sure that files that need to be written/read/executed by the server can accessed by the apache user as well as the user you setup to upload/edit files on the web server. I added them to a ‘web’ group and set the permissions on the site accordingly.

  4. Hi there!
    Same theme, same subject in common (open source) then our opinions part ways!

    No flame war, no rudeness, just my opinion of Mono (bearing in mind that at work im caught in a .net (sic))

    Mono sponsored by Novell, Novell the official bed partner of Microsoft (IMO)

    Ask yourself this, MS used patent power to get Novell to sign on board. Why would it sit back and allow Novell to sponsor Mono if it didnt have some other motive at work here?

    Call it paranoid ramblings of a 30+r who never grew out of 68k asm or the A500 demo-scene, or maybe, just maybe, there is something more to the “Wonderful” gift of Mono.

    “Beware of a Novell bearing gifts”

    • Roy, I’m glad this helped. Great job finding that bug! That’s one of the great things about OSS, the ability to find and fix things like that.

      I found this guide about debugging in mono, did you try the methods in there, or did it not work trying to debug the framework?

  5. Many thanks, this guide worked perfectly for me (to the letter!) on CentOS 5.2 with Mono 2.4 sources. 😀

    BTW, the httpd-devel package is required by the mod_mono compile if apxs (Apache Extension Tool) is not on your machine.

    And if you need to install gcc, use:

    # yum install gcc-c++

  6. Pingback: How to Install XSP and Integerate XSP With Apache 2 Under CentOS 5 | RubyPDF Blog

  7. Thank you for this wonderful article… I also had to installed the follwoing packages for the RHEL5.x env:

    yum install gcc-c++
    yum install glibc-headers
    yum install g++
    yum install glibc
    yum install glibc-devel
    yum install kernel-headers
    yum install build-essential
    yum install libc6-dev
    yum install libc-devel
    yum install gcc
    yum install bison
    yum install gettext
    yum install glib2-devel

  8. Thanks for the help. I was stuck building xsp one whole day; and the solution was:

    export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

  9. I’m very confused about mono, why i’m always failed if i want to try run script .aspx via browser. I’m using mono in centos 5.2 but failed and failed. May you give suggestion why i always failed to run .aspx (just see hello world).

    best regards

  10. I’ve tried this under Centos 6.3 and Mono 3.0.6. Unfortunately I get this error when trying to compile XSP (2.10.2):

    checking for MONO_MODULE… configure: error: Package requirements (mono >= 2.10.0) were not met:

    No package ‘mono’ found

    Consider adjusting the PKG_CONFIG_PATH environment variable if you
    installed software in a non-standard prefix.

    I have run the command “export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig” but it doesn’t help, probably because that directory doesn’t exist :/ Has something changed between these versions?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s