miércoles, 28 de enero de 2009

Steps to deploy an ASP.NET 2.0 web application in Apache 2 using mod_mono 2.2 (In OpenSuse 11)

this is a quick list of the steps required to deploy .Net applications under Apache 2 and mod_mono in OpenSuse 11

  1. Compile your web application. You can do it on Linux using MonoDevelop or using Visual Studio 2008, we usually compile it on Linux just to be sure the website will no have problems to start.
  2. Create a folder for your application.

    In our case we created a folder named "WebApp " under this directory:

    /usr/share/mono/asp.net/apps/

    just because there were other demo applications that come with mono.

    Be sure to give this folder the right permissions. open a Console and log in as the root user (sudo -s) and move to the folder. Use the chmod command to change the permissions if necessary (chmod 777 ./ will enable all the permissions under this folder, you can try adding only the necessary access level, because 777 enable all of them)

  3. copy the contents of the compiled web application to the new folder created.
  4. navigate to the folder "/etc/apache2/conf.d" and create a text file named "WebApp.conf"
  5. copy this code inside the file
        Alias /WebApp /usr/share/mono/asp.net/apps/WebApp
        MonoApplicationsConfigFile WebApp /etc/xsp/2.0/applications-available/WebApp.webapp
        MonoServerPath WebApp "/usr/bin/mod-mono-server2"
        MonoSetEnv WebApp MONO_IOMAP=all
        <Location /WebApp>
         Allow from all
         Order allow,deny
         SetHandler mono
         MonoSetServerAlias WebApp
        </Location>
    
  6. As you can see in the line 2 we point to a WebApp file that should be located in the /etc/xsp/2.0/applications-available/, so navigate to that folder an create a WebApp.webapp text fileand put this code inside this file:
    <?xml version="1.0" ?>
       <web-application>
        <name>WebApp</name>
        <vpath>/WebApp</vpath>
        <path>/usr/share/mono/asp.net/apps/WebApp</path>
        <enabled>true</enabled>
       </web-application>
    
  7. Now is time to restart apache, so run this command: "apache2ctl restart".
  8. Now open your browser and navigate to http://localhost/WebApp/Default.aspx (if Default.aspx exist or maybe other page that you have in the site)
  9. If all went without errors now you can enjoy your new website running under Apache 2 using mod_mono 2.2

Notes: There a lot of things that could go, wrong, maybe you will need to first Install Apache 2, if you don't already have it in your Linux distro, or maybe the mod_mono 2.2. Those tasks are out of the scope of this post. The present list of steps were written here just to never forget them.if you need help to install apache 2 or mod_mono, or even MONO 2.2, then you will need to do some googling by yourself. sorry :(

No hay comentarios: