[Mono-list] Got It Working!! How-To: Mono 2.0, Apache2, Ubuntu 10.04 With AJAX Example.

used2could used2could at gmail.com
Sun Oct 19 23:00:15 EDT 2008


Introduction

Here is my How-To on installing and configuring Mono 2.0 (Allows ASP.NET &
AJAX support) and Apache2 to run on Ubuntu 10.04 with an example to test
ASP.NET/AJAX. 

Background 

This is my first attempt to use anything other than a windows based machine.
I had such a hard time finding help so I thought I would document my efforts
to help someone running into the same problems I did. Hopefully this will
save you the week it took me to get it running. The simple install of Mono
and the mod-mono for apache via apt-get was riddled with problems so I had
to build from the sources to make sure I got the most up to date versions. 

How-To

I am assuming you have a fresh install of Ubuntu Hard (10.04) . If not you
can download the ISO file and burn it to a CD. The installation of Ubuntu is
amazingly simple.  

Let's Start! 

Open a Terminal  
 (Applications > Accessories > Terminal) 

$ sudo su
 #You'll be prompted to enter your password to elevate your user (Give's it
Admin rights)
$ aptitude upgrade
 # Choose "Y" (yes) for any prompts (This could take a while)
$ aptitude install bison libgettextpo-dev gettext libgettextpo0 gettext-base
subversion automake libtool autoconf glibc-2.7-1 bglibs-dev libglib-dev
libglib2.0-0 libglibmm-2.4-dev
 # Choose "Y" (yes) for any prompts
$ cd /
$ mkdir /MonoSources
$ cd /MonoSources
$ svn co svn://anonsvn.mono-project.com/source/trunk/mono
 #This will take a while
$ svn co svn://anonsvn.mono-project.com/source/trunk/mcs
 #This will take a while
$ svn co svn://anonsvn.mono-project.com/source/trunk/libgdiplus
$ cd /mono
$ ./autogen.sh --prefix=/usr
 #This will take a very long time
$ make get-monolite-latest
 #Grab a bite to eat. You'll be here for a while
$ make EXTERNAL_MCS=false
$ make
 #Fix a drink. It takes a bit for this to complete.
$ make install
 #Last long part. be patient...
$ aptitude install apache2 libapache2-mod-mono  mono-apache-server2
mono-gmcs
 # Choose "Y" (yes) for any prompts
$ nano /etc/apache2/sites-enabled/000-default
 #Clear out all of 000-default's existing content and replace it with the
below code:
#################################################################
NameVirtualHost *
<VirtualHost *>
        ServerAdmin webmaster at localhost

        DocumentRoot /MonoSources/

        ErrorLog /var/log/apache2/error.log

        LogLevel warn

        CustomLog /var/log/apache2/access.log combined

          MonoUnixSocket default /tmp/.mod_mono_server2
          MonoServerPath default /usr/bin/mod-mono-server2
          AddType application/x-asp-net .aspx .ashx .asmx .ascx .asax
.config .ascx
          MonoApplicationsConfigDir default /etc/mono-server2
          MonoPath default /usr/lib/mono/2.0:/usr/lib:/usr/lib/mono/2.0
             AddMonoApplications default "/:/MonoSources/"
               #<Directory /usr/share/asp.net2-demos>
                <Directory /MonoSources/>
                 SetHandler mono
                   <IfModule mod_dir.c>
                      DirectoryIndex Default.aspx
                   </IfModule>
               </Directory>
</VirtualHost>
#################################################################

# ctrl+x to exit, Y to agree to save.

$ cd /MonoSources
$ nano Default.aspx
 #This creates a new page. Paste the following content in this new file
(Default.aspx) excluding the #'s

#############################################################################
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="TestMono._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="smgTest" runat="server" />
        <asp:Label ID="lblStatic" runat="server" />

        <asp:UpdatePanel ID="pnlTest" runat="server">
            <ContentTemplate>
                <asp:Label ID="lblTest" runat="server" />
                <asp:Button ID="btnTest" Text="Test Time Stamp"
OnClick="btnTest_Click" runat="server" />
            </ContentTemplate>
        </asp:UpdatePanel>

    </div>
    </form>
</body>
</html>
#############################################################################
 # ctrl+x to exit, Y to agree to save.

$ nano Default.aspx.cs
	#This creates a new page. Past the following content in this new file
(Default.aspx.cs) excluding the #'s
#############################################################################
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

namespace TestMono
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            lblStatic.Text = DateTime.Now.ToString();

        }

        protected void btnTest_Click(object sender, EventArgs e)
        {
            lblTest.Text = DateTime.Now.ToString();
        }
    }
}
#############################################################################
 # ctrl+x to exit, Y to agree to save.

$ mconfig af -t=web AJAX
 # This will make a Web.config file for you with the needed references for
ajax.
$ /etc/init.d/apache2 restart

Open up a browser and go to your new test asp.net page.
(127.0.0.1/Default.aspx)
		 
History

All the online documentation that showed how to install from svn or sources
used  ./autogen.sh --prefix=/usr/local. This i think is what kept messing me
up. It needs to be set to --prefix=/usr.
-- 
View this message in context: http://www.nabble.com/Got-It-Working%21%21-How-To%3A-Mono-2.0%2C-Apache2%2C-Ubuntu-10.04-With-AJAX-Example.-tp20062512p20062512.html
Sent from the Mono - General mailing list archive at Nabble.com.



More information about the Mono-list mailing list