Wednesday, November 12, 2008

Mono on Fedora 9 - Installation/Setup/Configuration

Previously, I have setup Mono on Fedora 8 using a prebuilt image.

See blog post: http://endurotracker.blogspot.com



Summary:

Install and configure Mono (.net framework) on Fedora 9.

Notes: Yum did not seem to detect the dependencies of between xsp and mod_mono
if you follow the order of the steps at : http://www.inprose.com/articles/10-enable-aspnet-support-in-fedora-linux.html
You end up with fc9 version of mod_mono, but a fc10 version of xsp which is bad.
You want all your libraries to be a fc10 version.
Your web server, Apache can be the fc9 version.



Steps:



1) Install Apache fc9: yum install httpd
2) Disable SELinux, from UI , click System -> Administration -> SELinux Management ( from linked article above mentions that from command line: setenforce 0 , but I could not get this to work)
3) Install fc10 mod_mono from rawhide repository ( which depends on mono-core, mono-web, and xsp, so this will can installed all at the same time in this step):
yum install --enablerepo=rawhide mod_mono
4) Grant permissions to apache user to execute and create directories under var/run ( apache runs under user: apache by default), command line: chmod 777 /var/run -R



5) After the successful install we need to configure Apache to allow it to run Mono applications (typical usage asp.net web pages, and .asmx web services).
In this test case , we are using the test asp.net pages that got installed under /usr/lib/xsp/test when we installed xsp above in the install mod_mono step.
On completion of this step, we can open our browser and go to http://localhost/test to see our Mono Test Page in action.



Edit /etc/httpd/conf/httpd.conf



Add these entries to the end of the file:
#Test Mono Setup
MonoAutoApplication enabled
MonoServerPath test /usr/bin/mod-mono-server2
Alias test "/usr/lib/xsp/test"
MonoApplications test "/test:/usr/lib/xsp/test"

MonoSetServerAlias test
SetHandler mono

MonoSetEnv MONO_IOMAP=all
6) Done! Go to go to http://localhost/test to test your setup.


7 comments:

  1. When I try to use yum, I get problem like this

    [root@trees64 bin]# yum install --enablerepo=rawhide mod_mono
    updates-newkey | 3.0 kB 00:00
    updates-newkey/primary_db | 5.4 MB 00:00
    fedora | 2.4 kB 00:00
    fedora/primary_db | 7.6 MB 00:00
    updates | 2.6 kB 00:00
    updates/primary_db | 11 kB 00:00
    rawhide | 3.8 kB 00:00
    Setting up Install Process
    Parsing package install arguments
    Resolving Dependencies
    --> Running transaction check
    ---> Package mod_mono.x86_64 0:2.4-4.1.fc11 set to be updated
    --> Finished Dependency Resolution
    Dependencies Resolved

    ================================================================================
    Package Arch Version Repository Size
    ================================================================================
    Updating:
    mod_mono x86_64 2.4-4.1.fc11 rawhide 55 k

    Transaction Summary
    ================================================================================
    Install 0 Package(s)
    Update 1 Package(s)
    Remove 0 Package(s)

    Total size: 55 k
    Is this ok [y/N]: y
    Downloading Packages:
    Running rpm_check_debug
    ERROR with rpm_check_debug vs depsolve:
    rpmlib(FileDigests) is needed by mod_mono-2.4-4.1.fc11.x86_64
    Complete!
    (1, [u'Please report this error in http://yum.baseurl.org/report'])

    Do you know how to solve this?

    ReplyDelete
  2. It looks like your rawhide repository is pointing to 64bit Fedora 11 repository. I installed and tested this on x386 (Amazon Small Instance) using the Fedora 10 repository. However, it looks like you need to upgrade your rpmlib to a newer version if you want to use the fedora 11 repository (fc11).
    If you base Fedora version is Fedora 10, then you should be able to just use: yum install mod_mono
    "Rawhide" means the development version of Fedora, at the time I wrote this Fedora 9 was current version, and Fedora 10 was the "development" version.

    ReplyDelete
  3. If your base system is Fedora 9, you could upgrade to Fedora 10 which is now the Production version, and then just run: yum install mod_mono

    I actually built a new server today, I started with base of Fedora 9, then upgraded it to Fedora 10, and then ran: yum install mod_mono.
    To upgrade from Fedora 9 to Fedora 10 , you can use this link:
    http://fedoraproject.org/wiki/Upgrading_Fedora_using_yum

    ReplyDelete
  4. my system is
    Linux trees64.GRC 2.6.27.24-78.2.53.fc9.x86_64 #1 SMP Wed May 20 23:25:40 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux

    when I look at my system...httpd log

    it write

    System.InvalidOperationException: mod_mono and xsp have different versions.
    at Mono.WebServer.ModMonoRequest.GetInitialData () [0x00000]
    at Mono.WebServer.ModMonoRequest..ctor (System.Net.Sockets.NetworkStream ns) [
    0x00000]
    at Mono.WebServer.RequestReader..ctor (System.Net.Sockets.NetworkStream ns) [0
    x00000]
    at Mono.WebServer.ModMonoWorker.InnerRun (System.Object state) [0x00000]
    at Mono.WebServer.ModMonoWorker.Run (System.Object state) [0x00000]
    [Fri Jun 05 12:57:54 2009] [error] (104)Connection reset by peer: read_data fail
    ed
    [Fri Jun 05 12:57:54 2009] [error] Command stream corrupted, last command was -1

    but when I type 'xsp' in system...

    it told me the server start @ port 8080

    when I link to port 8080, it show me the xsp error page(no page found but server start)

    XSP

    [root@trees64 xsp]# ls -ltr
    total 12
    drwxr-xr-x 5 root root 4096 2009-06-04 23:45 test
    drwxr-xr-x 2 root root 4096 2009-06-04 23:45 2.0
    drwxr-xr-x 2 root root 4096 2009-06-04 23:45 1.0

    [root@trees64 xsp]# pwd
    /usr/lib64/xsp


    is that means my xsp and mono already installed?
    or the config things wrong?

    here is part of httpd.conf

    AddHandler mono .aspx .ascx .asax .ashx .config .cs .asmx

    Alias /test2 "/usr/lib64/xsp/test"
    MonoApplications "/test2:/usr/lib64/xsp/test"

    Directory "/usr/lib64/xsp/test"
    SetHandler mono
    DirectoryIndex index.aspx
    /Directory

    ReplyDelete
  5. This was the problem with the Fedora 9 version of mod_mono, so I needed to force it to use the Fedora 10 version of mod_mono.
    I think you need to uninstall xsp and mod_mono,
    and then reinstall mod_mono using yum (fedora 10 or newer repository) which will install mod_mono and xsp at the same time in order to make sure you are using the same versions of mono for both mod_mono and xsp.

    ReplyDelete
  6. thank for reply

    I upgrade the fedora to 10

    xsp.x86_64 2.0-4.fc10 installed
    mod_mono.x86_64 2.0-6.fc10 installed

    here is mono and xsp I install..

    but when I setup httpd.conf

    I get the error msg :
    [root@trees48 conf.d]# /etc/init.d/httpd restart
    Stopping httpd: [ OK ]
    Starting httpd: [Sat Jun 06 23:16:04 2009] [crit] (13)Permission denied: Failed to create shared memory segment for backend 'default' at '/var/run/mod_mono_dashboard_default_2'.
    [ OK ]

    ReplyDelete
  7. apache runs under the user apache, so you need to grant the user apache rights to /var/run
    You can grant apache rights by doing this command:
    chmod -R 777 /var/run

    ReplyDelete