CHAN - Bloat free ASP.Net
Introduction | About | Roadmap | Changelog | Licensing | Reference | Download | Guides: Windows , Linux/Mono , Building
OpenSUSE, Mono + Apache installation guide
Disclaimer: This guide assumes you are working on a clean install of OpenSUSE, and not a production machine. It may be woefully innaccurate, have missing steps or present incorrect information, follow at your own risk. The author accepts no responsibility whatsoever for any damages or losses of any kind caused by following the steps laid out below.
This guide steps through the entire process of setting up Apache and Mono on a clean install of OpenSUSE 11.0, it then goes on to show you how to host the Chan_Demo site but up to that point it holds true for any ASP.Net 2.0 based site. It's aimed somewhat at the linux beginner level so goes into a lot of detail and includes quite a few screenshots too.
The first step is to install OpenSUSE on your target system, and you need to remember your root password, you'll be using it a few times in this guide. Finally, assume "Lizard" means "Start Menu Button"!
Installing Apache and Mono
- Lizard > Computer > Install Software
- Enter your root password when prompted
- Type "apache" into the search box
- Find and tick apache2
- Click OK / Next to all dialogs till it has finished
- When it asks "Install more software?" click Yes
- Now select the "Repositories" menu and click "Repository Manager"
- Click "Add" (towards the bottom left)
- Select "Specify URL" and Click Next
- Enter "Mono" as the source name
- Enter http://ftp.novell.com/pub/mono/download-stable/openSUSE_11.0 as the url
- Click OK / Next / etc.
- Select the new "Mono" entry in the repository list and click the "Edit" button to review the entry, it should look like this:
- Click OK and Next to all dialogs till it has finished
- Exit the repository manager
- You should now be back at the "Install Software" screen
- Search for "mono"
- Find and tick "Mono Complete", the other Mono entries and dependencies will sort themselves out for you
- Click OK / Next to all dialogs till it has finished
- Apache and Mono should now be installed
Configuring Apache and Mono
This requires editing some configuration files, but to make things easier we're going to open a file browser as root, so we can just get on with it. But running Konqueror as root can be a Very Bad Thing, so keep your fingers well away from that delete key!
- Press ALT+F2 and type in "kdesu konqueror" at the prompt
- Click Launch / Next / OK
- Enter your root password when prompted
- You will now have Konqueror open as root, meaning you can edit, move or delete anything on the system
- Go to the url bar, type in "/etc/apache2/" and hit return
- Find and double click on "httpd.conf"
- You should now have it open in a text editor
- Find the part that looks like this):
# optional mod_status, mod_info Include /etc/apache2/mod_status.conf Include /etc/apache2/mod_info.conf
- Add this extra "Include" to the list:
# mono Include /etc/apache2/conf.d/mod_mono.conf
- According to the wisdom of the internet the path to mod_mono.conf might be "/etc/apache2" instead, but we edit it in the next bit anyway so we can double check we have the correct path
Enable Mono ASP AutoConfiguration
AutoConfiguration makes it easier for ASP.Net applications to be hosted under Mono by not requiring you to configure each subdirectory to act as an Application like you would with IIS. It basically allows it to find the correct web.config and bin directory for your site without being told where to look.
- Find the mod_mono.conf file and double click it to edit it
- Find this bit:
<IfModule !mod_mono.c>
LoadModule mono_module /usr/lib/apache2/mod_mono.so
AddType application/x-asp-net .aspx
</IfModule>
- Add two lines to the top of that bit so that it thn looks like this:
<IfModule !mod_mono.c>
MonoServerPath "/usr/bin/mod-mono-server2"
MonoAutoApplication enabled
LoadModule mono_module /usr/lib/apache2/mod_mono.so
AddType application/x-asp-net .aspx
</IfModule>
Start Apache
Apache's web server runs as httpd, but we need to start a service named apache2. This is similar to how IIS runs a web server, an ftp server and a seperate aspnet process.
- Lizard > Computer > YaST
- Enter your root password at the prompt
- Click the "System" side panel item
- Click "System Services (runlevel)" in main panel
- Sort by "Service" and find "apache2"
- Select it then click the "Enable" button towards the bottom left
- Iit should declare "returned 0 (success!)"
- Click "Finish" and ok the save dialog
- It will your choice here on the next boot and automatically start Apache for you
Restarting Apache
You may need to do this if the Mono AutoConfiguration hasn't kicked in (If you see a "Couldn't find part of class" error on your ASPX page) or you've edited one of the config files again.
- Open a command prompt / terminal
- Enter "sudo /etc/init.d/apache2 restart"
- Enter your root password
- You can also send "start" and "stop" instead of "restart", it's kind of like the reverse of Windows' NET START (service) command
Writing a Test ASPX page
We're almost there, what we need to do now is create a very simple test page to show that the Mono ASP engine is running.
- Using your root-Konqueror go to "/srv/www/htdocs"
- Right-click > "Create New" > "Text File"
- Name it "Default.aspx" with a capital D
- Click (Double Click?) it to open it - it should open in a text editor
- Enter the following and save it (remember that this is Case Sensitive!):
<% @ Page Language="C#" %> <% Response.Output.Write( DateTime.Now.ToString() ); %>
- Open Firefox
- Click the URL bar, enter "http://localhost/" and hit return
- If you see the date and time then it worked!
Hosting Chan Demo
If you got this far then you could - in theory - host any mono compatible ASP.Net site on your linux box, if you're not interested in Chan because you got here via google then thanks for dropping by, glad i could help! (But you really should check Chan out and throw away that evil MS ASP model...)
- Get the Chan_Demo.zip from cyclomedia.co.uk
- Save (or copy) it into "/srv/www/htdocs"
- Unzip it, if you can't get Ark to work (nobody can) then be brave and do it from the command prompt: "unzip Chan_Demo.zip"
- Make sure (rename it if you need to) that the "Chan_Demo" folder is named "chan_demo" in lower case
- Now open the web.config file that is in the new chan_demo folder and set the following entries thus:
- Open Firefox
- Click on the URL bar, enter "http://localhost/chan_demo/Self_Test.aspx" and click return
- Behold!
The chan_demo site to date is only expecting itself to be hosted as web-root , not under a sub directory, so the CSS and menu links wont work. Chan 0.8.1 already fixes this by having built-in template regions for Site_Root and Http_Root from web.config, but until then you'll need to fix the links yourself.
Making the site visible to (Windows) machines
Hosting a web site is no good unless people can actually see it, you may need to enable some settings to get Windows machines to see it specifically. First a quick test:
- Edit the chan_demo/web.config and change the Chan_Http_Root key to contain the server name instead of "localhost"
- Go to a different computer on the same network
- Open a web browser
- Click on the URL bar, enter "http://[servername]/chan_demo/Self_Test.aspx", where [servername] is the name of your server, mine's called "istanbul", so i'd enter "http://istanbul/chan_demo/Self_Test.aspx". (Where's that document again? Istanbul.)
- If that didnt work try the IP address instead of [servername], e.g. "http://192.168.1.66/chan_demo/Self_Test.aspx"
- If that DID work and you're currently sat at a windows machine you need to install samba on the linux machine
Installing and Configuring Samba
- Lizard > Computer > Install Software
- Enter your root password at the prompt
- Type "samba" into the search box and hit enter
- Find and click "samba" in the list, any other samba-related entries it needs will tick themselves
- Click OK / Next / Yes to everything and exit the Software Installer
- Lizard > Computer > Yast2
- Select "Network Services" on the left, then "Windows Domain Membership" on the right
- It may process for a while and mutter about "Samba Client Configuration", wait for it to finish
- If you arrived at a screen titled "Windows Domain Membership" then you're nearly there
- just enter your domain/workgroup in the relevant box and click "Finish"
- Test the chan_demo site from another machine again using the machine name, it should work
- If it didn't, you can try setting Lizard > Computer > Yast2 > "Network Services" > "Samba Server" > "Identity" > "NetBIOS Hostname" to the machine name too. The "NetBIOS hack" usually works for windows machines as far back as Win95! If this doesnt work you're on your own!
Here endeth the Chan, Apache, Mono, Samba and OpenSUSE tutorial, hopefully someone out there will find it useful!