A day with .Net

My day to day experince in .net

Archive for January, 2012

Host ASP.NET in Linux

Posted by vivekcek on January 29, 2012

I think developing .net application with Linux will be cost effective.You don’t need to pay for Microsoft.But it’s in initial phase you wont get full advantage of

Microsoft .NET frame work in Linux.If you are interested can read about Mono project,sharp develop etc..

Today i am going to talk about hosting a .NET 2.0 web site in Linux.


1. Ubuntu Linux 11.10(32 bit) or earlier.
2. Need high speed internet connection.


1. Install fresh copy of Ubuntu.Can be installed in virtual environment like virtual pc and VMware.
2. Open the Terminal (CNTRL+ALT+T).
3. Log-in as root:

vivek@ubuntu:~$ sudo -s -H

[sudo] password for vivek:

4. Install apache
root@ubuntu:/home/vivek# sudo apt-get install apache2

5. Check if Apache is working. Open Firefox browser and then paste this URL in the browser address bar then press enter:

You should be able to see a page that says that Apache is working

6. Now install mod_mono:
root@ubuntu:/home/vivek# sudo apt-get install mono-apache-server2 libapache2-mod-mono

7. Enabling Mod_mono in Ubuntu
root@ubuntu:/home/vivek# sudo a2enmod mod_mono

8. Now to enable the auto hosting feature of mod_mono:
root@ubuntu:/home/vivek# sudo a2enmod mod_mono_auto

9. Restart Apache server:
root@ubuntu:/home/vivek# sudo /etc/init.d/apache2 restart

10. Change the owner of the www webroot to your Ubuntu username. By default the owner of the www webroot path (/var/www/) is the root. You need to change it to your

username for convenience. Follow the steps:
a.) In the command line, login as root.
b.) Go to the root directory
root@ubuntu:/home/vivek# cd /
c.) Go to /var/
root@ubuntu:/home/vivek# cd var
d.) Change the owner of the www to your username(replace vivek your own Ubuntu username):
root@ubuntu/var# chown -R codex-m:codex-m www
e.) Restart Apache server:
root@ubuntu:/home/vivek# sudo /etc/init.d/apache2 restart

11. Open a Text Editor copy the code

<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<title>ASP.NET Test Page</title>
<form id="form1" runat="server">
<asp:label id="lbl1" runat="server">Hi, this is an ASP.NET Test Page! If you see this message then mod_mono module in Apache is working properly. Thank you!



12. Save the file as testpage.aspx and save it to /var/www path.
13. In the web browser address bar, enter this URL and press enter:


The output in your browser should look like this:


Posted in Mono .Net Linux | Tagged: , , , , , , , , | 1 Comment »