<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Bennyland &#187; mono</title>
	<atom:link href="http://blog.bennyland.com/tag/mono/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.bennyland.com</link>
	<description>this server is running in my bedroom - benny’s learning how to run a linux server</description>
	<lastBuildDate>Thu, 06 Jan 2011 16:41:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Serving ASP.NET pages in Apache on CentOS 5</title>
		<link>http://blog.bennyland.com/2010/02/06/serving-asp-net-pages-in-apache-on-centos-5/</link>
		<comments>http://blog.bennyland.com/2010/02/06/serving-asp-net-pages-in-apache-on-centos-5/#comments</comments>
		<pubDate>Sat, 06 Feb 2010 18:59:32 +0000</pubDate>
		<dc:creator>benny</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[asp]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[mono]]></category>
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://blog.bennyland.com/?p=78</guid>
		<description><![CDATA[I'm starting to love ASP.NET and the ability to do everything in C# (I'm currently working on an internal silverlight app at work and creating a RESTful API is more fun in C#). Anyway, you can do a yum install mod_mono, but it's a pretty old version so I did some research and found a [...]]]></description>
			<content:encoded><![CDATA[<p>I'm starting to love ASP.NET and the ability to do everything in C# (I'm currently working on an internal silverlight app at work and creating a RESTful API is more fun in C#).  Anyway, you can do a yum install mod_mono, but it's a pretty old version so I did some research and found a <a href="http://poormanstech.blogspot.com/2007/05/installing-mono.html">guide on building it yourself</a> along with two other guides that were roughly the same, but not as good... (<a href="http://blog.rubypdf.com/2009/10/23/how-to-install-mono-2-4-2-3-on-centos-5/">1</a>, <a href="http://init.sh/?p=74">2</a>) and somehow ended up with a working server.  This is a companion to that guide with more up to date versions of things. (it took me SEVERAL trial and error attempts to get things working :/ so hopefully i didn't miss any steps)</p>
<p>Let me preface this with the fact that if you're running one of the already supported OSs (debian or unbuntu for instance) you shouldn't follow this guide - instead you should just look on the mono website for information.<br />
<span id="more-78"></span><br />
First thing I did was grab the most up-to-date mono and xst sources (i matched versions)</p>
<pre class="brush: bash; title: ;">cd /tmp
wget http://ftp.novell.com/pub/mono/sources/mono/mono-2.6.tar.bz2
wget http://ftp.novell.com/pub/mono/sources/mod_mono/mod_mono-2.6.tar.bz2
wget http://ftp.novell.com/pub/mono/sources/xsp/xsp-2.6.tar.bz2</pre>
<p>Then unpack everything</p>
<pre class="brush: bash; title: ;">tar -jxvf mono-2.6.tar.bz2
 tar -jxvf xsp-2.6.tar.bz2
 tar -jxvf mod_mono-2.6.tar.bz2</pre>
<p>then build mono first (change anything on the ./configure line to your liking, I do suggest picking a place to put mono, letting it install wherever it wants to makes the rest of the process very painful!):</p>
<pre class="brush: bash; title: ;">cd /tmp/mono-2.6
./configure --prefix=/opt/mono
make ; make install
echo export PKG_CONFIG_PATH=/opt/mono/lib/pkgconfig:$PKG_CONFIG_PATH&gt;&gt;~/.bash_profile
echo export PATH=/opt/mono/bin:$PATH&gt;&gt;~/.bash_profile
source ~/.bash_profile</pre>
<p>after a bit you'll have mono installed <img src='http://blog.bennyland.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Now build xsp (i had to add pkgconfig to an environment variable to get it to work)</p>
<pre class="brush: bash; title: ;">cd /tmp/xsp-2.6
./configure --prefix=/opt/mono
make ; make install</pre>
<p>Finally build mod_mono, you'll probably need to tell it where apache's apr-config is... it took a while for me to find it.. heh</p>
<pre class="brush: bash; title: ;">find / -iname apr*config
cd /tmp/mod_mono-2.6
./configure --prefix=/opt/mono --with-mono-prefix=/opt/mono --with-apr-config=/usr/bin/apr-1-config
make ; make install</pre>
<p>you should now find mod_mono in your apache modules dir (in my case /usr/lib64/httpd/modules/)</p>
<pre class="brush: bash; title: ;">ls /usr/lib64/httpd/modules/mod_mono*
17 Feb  5 22:54 /usr/lib64/httpd/modules/mod_mono.so -&gt; mod_mono.so.0.0.0
145511 Feb  5 22:54 /usr/lib64/httpd/modules/mod_mono.so.0.0.0
</pre>
<p>the mod_mono install seems to have automatically created mod_mono.conf in my httpd/conf folder, but you may want to make sure it's there</p>
<pre class="brush: bash; title: ;">vim /etc/httpd/conf/mod_mono.conf</pre>
<pre class="brush: plain; title: ;"># mod_mono.conf

# Achtung! This file may be overwritten
# Use 'include mod_mono.conf' from other configuration file
# to load mod_mono module.

&lt;IfModule !mod_mono.c&gt;
    LoadModule mono_module /usr/lib64/httpd/modules/mod_mono.so
&lt;/IfModule&gt;

&lt;IfModule mod_headers.c&gt;
    Header set X-Powered-By &quot;Mono&quot;
&lt;/IfModule&gt;

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 .vb
AddType application/x-asp-net .master
AddType application/x-asp-net .sitemap
AddType application/x-asp-net .resources
AddType application/x-asp-net .skin
AddType application/x-asp-net .browser
AddType application/x-asp-net .webinfo
AddType application/x-asp-net .resx
AddType application/x-asp-net .licx
AddType application/x-asp-net .csproj
AddType application/x-asp-net .vbproj
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
</pre>
<p>Now, you need to get this to work with ISPConfig3, since if you've followed my other tutorials, that's what you have running things on the back end.</p>
<p>Modify your httpd.conf file to include mod_mono.conf.  You want to do this at the very bottom, just before the NameVirtualHost directives (ISPConfig puts 3 directives at the very bottom of httpd.conf, you want to place this line just before them:</p>
<pre class="brush: bash; title: ;">vim /etc/httpd/conf/httpd.conf</pre>
<pre class="brush: plain; title: ;">Include /etc/httpd/conf/mod_mono.conf
# this is where ISPConfig's stuff is, don't modify it, this comment is so you know where to put the line above the comment <img src='http://blog.bennyland.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />
NameVirtualHost *:80
NameVirtualHost *:443
Include /etc/httpd/conf/sites-enabled/
</pre>
<p>now, restart apache</p>
<pre class="brush: bash; title: ;">service httpd restart</pre>
<p>and open up ISPConfig.  go to sites > website > Select the website you want to add a mono enabled directory to, then click on the "Options" tab for that site.  Enter the following into the Apache Directives (<strong>replace /var/www/path/to/the/web/folder with the path to that site's web folder</strong>)</p>
<pre class="brush: plain; title: ;">MonoPath default &quot;/opt/mono/lib/mono/2.0&quot;
MonoServerPath default /opt/mono/bin/mod-mono-server
AddMonoApplications default &quot;/test:/var/www/path/to/the/web/folder/test&quot;
&lt;location /test&gt;
	MonoSetServerAlias default
	SetHandler mono
&lt;/location&gt;
</pre>
<p>and finally restart httpd</p>
<pre class="brush: bash; title: ;">service httpd restart</pre>
<p>here's a test page, create it in your /var/www/path/to/the/web/folder/test directory and set the permissions to whatever the other site's permissions are, or apache.apache</p>
<pre class="brush: xml; title: ;">&lt;html&gt;
&lt;body&gt;
&lt;% Response.Write(&quot;Hello World!&quot;); %&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<p>now, once ISPConfig restarts apache (sometimes this is instant but i've seen it take up to 5 minutes) you'll see Hello World! displayed</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bennyland.com/2010/02/06/serving-asp-net-pages-in-apache-on-centos-5/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

