Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mono 2.11 with nginx or apache

I have installed parallel Mono (2.11.3) following these instructions: http://www.integratedwebsystems.com/2012/04/install-mono-2-11/ Now I want to run my ASP.NET site on this Mono instance. I have created an empty MVC 4 site using the "Internet site" template in VS 2010 and published it to the Linux box running Mono.

I have succeeded in running it via xsp4 following these instructions ( http://www.integratedwebsystems.com/2011/06/get-mvc3-razor-running-on-mono/) to set up the environment variables prior to running xsp4. It works without major problems (I see that some new features, like CSS bundling, do not work, but I will deal with it later).

Now, I would like to use the production server like apache or nginx. However, it seems almost impossible, and it seems that I'm not the only one with this problem. For example, using this simple nginx configuration

server
{
    listen 80;
    server_name mvctest.mono;

    access_log /var/www/mvctest/log/access.log;
    error_log /var/www/mvctest/log/error.log debug;

    location /
    {
             root /var/www/mvctest/;
             index index.html index.htm default.aspx Default.aspx;
             fastcgi_index /Home;
             fastcgi_pass 127.0.0.1:9000;
             include /etc/nginx/fastcgi_params;
    }
}

results in 502 Bad Gateway error, and the log file says "upstream sent unexpected FastCGI record: 3 while reading response header from upstream". As for the Apache + mod_mono_server4, I have not moved past the error

Exception caught during reading the configuration file:
System.MissingMethodException: Method not found:     'System.Configuration.IConfigurationSectionHandler.Create'.
at     System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection (System.String configKey) [0x00000] in <filename unknown>:0 
at System.Configuration.ConfigurationManager.GetSection (System.String sectionName) [0x00000] in <filename unknown>:0 
at System.Configuration.ConfigurationManager.get_AppSettings () [0x00000] in <filename unknown>:0 
at Mono.WebServer.Apache.Server.get_AppSettings () [0x00001] in /opt/mono-2.11/build/xsp-2.10.2/src/Mono.WebServer.Apache/main.cs:208 
at Mono.WebServer.Apache.Server+ApplicationSettings..ctor () [0x0002a] in /opt/mono-2.11/build/xsp-2.10.2/src/Mono.WebServer.Apache/main.cs:63 

There are a lot of posts on this topic, even here on the Stackoverflow, but no real answers. However, some users do report that they succeeded in running MVC4 sites on mono with these servers, so I was wondering if anybody would like to share their configuration settings or step-by-step instructions?

like image 237
sdeni Avatar asked Oct 18 '12 18:10

sdeni


2 Answers

The install package is placing some files in the wrong place. For Apache, you'll have to move the file mod-mono-server4.exe from /usr/lib/mono/4.0 to /usr/lib/mono/4.5 and update the reference inside the file /usr/bin/mod-mono-server4.

If you were using XSP or FastCgi, the same treatment would be required for xsp4.exe and fastcgi-mono-server4.exe and their respective references in /usr/bin.

(I am starting to regret I followed down this Mono path... )

like image 75
MoonStom Avatar answered Oct 06 '22 02:10

MoonStom


Here's a script that solved my Mono 3.0.3/MVC 3/Nginx issues. After copying over the needed files, the site pulled up fine.

like image 45
Brett Avatar answered Oct 06 '22 00:10

Brett