<> ## See https://bugs.launchpad.net/ubuntu-docs/+bug/1437275 ## Also, instructions for a Non-Autohosting installation on newer releases is still missing. Mod_Mono is an Apache 1.3/2.0/2.2/2.4 module that provides ASP.NET support for the web's favorite server, Apache (http://httpd.apache.org). <> = Configuring mod_mono on Ubuntu = *The mod_mono packages and configuration on Ubuntu vary depending on the version of Ubuntu. *This guide assumes that you have read the official [[https://help.ubuntu.com/lts/serverguide/httpd.html|Ubuntu Apache 2 Documentation]] and understand how Ubuntu manages modules and virtual hosts. *'''Warning: installing mod_mono may uninstall the PHP Apache module. Apparently they cannot co-exist.''' *[[http://mono-project.com/AutoHosting|Understand the difference between Autohosting and Non-Autohosting setup.]] Installation instructions are outlined below for both. * Refer to the [[http://www.mono-project.com/docs/web/mod_mono/|Official mod_mono Documentation]] for a more detailed setup. == Autohosting Configuration == === ASP.NET 1.1 on Ubuntu 14.04 Trusty Tahr === 1) Install the mod_mono packages: {{{ sudo apt-get install libapache2-mod-mono mono-apache-server }}} 2) There's a [[https://bugs.launchpad.net/ubuntu/+source/mod-mono/+bug/1308047|known mod_mono package bug]] that may make the installation process hang when trying to restart apache2. The bug's comments mention a workaround, which is to open a second terminal (SSH connection), and stop apache2 manually: {{{ sudo service apache2 stop }}} 3) There's also [[https://bugs.launchpad.net/ubuntu/+source/xsp/+bug/1293481|a second bug in the configuration of the initial installation]]. To work around it, the /etc/mono-server4/mono-server4-hosts.conf file has to be modified, see the comments of the linked Launchpad bug report. === ASP.NET 2.0 on Ubuntu 12.04 Precise Pangolin === 1) If Apache is running, it must be stopped before installing mod_mono: {{{ sudo service apache2 stop }}} 2) Install the mod_mono and the mono development packages: {{{ sudo apt-get install libapache2-mod-mono mono-apache-server2 mono-devel }}} 3) Enable the Apache module: {{{ sudo a2enmod mod_mono_auto }}} 4) Restart Apache: {{{ sudo service apache2 restart }}} == Non-Autohosting Configuration == === ASP.NET 2.0 on Ubuntu 12.04 Precise Pangolin === '''1) Install packages''' To begin, you can easily install mod_mono using apt: ''(universe package sources must be active in /etc/apt/sources.list, see for example [[http://www.ubuntux.org/node/71|here]])'' {{{ sudo apt-get install libapache2-mod-mono }}} Optionally, if you would like to use [[http://quickstarts.asp.net/QuickStartv20/aspnet/doc/whatsnew.aspx|ASP.NET 2.0]], you need to install an additional package: {{{ sudo apt-get install mono-apache-server2 }}} '''2) Activate the module:''' {{{ sudo a2enmod mod_mono }}} '''3) Select the ASP.NET version''' The {{{/etc/apache2/mods-available/mod_mono.conf}}} file controls which version of ASP.NET is to be used. If you would like to use 2.0, and you installed the package as explained above, open this file in a text editor and follow the directions. '''4) Configure your web applications''' Applications are defined in ''.webapp'' files, located in either {{{/etc/mono-server/}}} or {{{/etc/mono-server2/}}} depending on which version of ASP.NET you are using. The format of these files are explained in the xsp man page. {{{ man xsp }}} '''5) Restart apache''' Restart apache so the new configuration is loaded. {{{ sudo service apache2 restart }}} === Example Configuration === Say we have an apache vhost ''example.com'' and we would like the URL {{{http://example.com/moo}}} to be an ASP.net application. First we declare the apache site configuration in {{{/etc/apache2/sites-available/example.com}}} and enable it. As mentioned earlier, this is explained in the [[https://help.ubuntu.com/12.04/serverguide/httpd.html|official Ubuntu documentation]]. {{{ ServerName example.com DocumentRoot /var/www/example.com/ Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny Allow from all SetHandler mono DirectoryIndex index.aspx index.html }}} With this configuration, our asp.net application (the aspx files, etc.) would be placed in {{{/var/www/example.com/moo/}}}. Next, you would create a corresponding webapp file. Let's pretend that we are using ASP.NET 1.x, so we are going to create {{{/etc/mono-server/example.com-moo.webapp}}}: {{{ MOO!! /moo /var/www/example.com/moo example.com }}} Reload apache, and you should be done! = Testing your setup = To test your setup, you can create a test page with the following content anywhere that Apache can see (i.e. /var/www/test.aspx or /var/www/html/test.aspx): {{{ <%@ Page Language="C#" %> ASP Test Page
ASP Test Page
}}} = Troubleshooting = == Standard output has not been redirected or process has not been started == After configuring mod_mono_auto, starting up with the test.aspx page gives the following error: {{{ Standard output has not been redirected or process has not been started. Description: HTTP 500. Error processing request. Stack Trace: System.InvalidOperationException: Standard output has not been redirected or process has not been started. at System.Diagnostics.Process.CancelErrorRead () [0x00000] at (wrapper remoting-invoke-with-check) System.Diagnostics.Process:CancelErrorRead () at Mono.CSharp.CSharpCodeCompiler.CompileFromFileBatch (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00000] at Mono.CSharp.CSharpCodeCompiler.CompileAssemblyFromFileBatch (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00000] at System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromFile (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00000] at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath, System.CodeDom.Compiler.CompilerParameters options) [0x00000] at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath) [0x00000] at System.Web.Compilation.BuildManager.BuildAssembly (System.Web.VirtualPath virtualPath) [0x00000] at System.Web.Compilation.BuildManager.GetCompiledType (System.String virtualPath) [0x00000] at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath (System.String virtualPath, System.Type requiredBaseType) [0x00000] at System.Web.UI.PageParser.GetCompiledPageInstance (System.String virtualPath, System.String inputFile, System.Web.HttpContext context) [0x00000] at System.Web.UI.PageHandlerFactory.GetHandler (System.Web.HttpContext context, System.String requestType, System.String url, System.String path) [0x00000] at System.Web.HttpApplication.GetHandler (System.Web.HttpContext context, System.String url, Boolean ignoreContextHandler) [0x00000] at System.Web.HttpApplication.GetHandler (System.Web.HttpContext context, System.String url) [0x00000] at System.Web.HttpApplication+c__Iterator2.MoveNext () [0x00000] }}} The reason may be the lack of gmcs in the path (the Mono C# compiler). With the installation process above you may only get gmcs2. The way to check is to see if you have either one: {{{ $ which gmcs }}} If this does not return a location, then you don't have gmcs. Try {{{ $ which gmcs2 }}} The best way to resolve the lack of gmcs is to install the mono-devel packages: {{{ $ sudo apt-get install mono-devel }}} Restart apache, and navigate back to test.aspx. You should now see the "ASP Test Page" label on the page. = External Links = * [[http://www.mono-project.com/docs/web/mod_mono/|Official mod_mono Documentation]] ---- CategoryAdministration