【问题标题】:Mono 2.11 with nginx or apache带有 nginx 或 apache 的 Mono 2.11
【发布时间】:2012-10-09 07:50:47
【问题描述】:

我已经按照以下说明安装了并行 Mono (2.11.3):http://www.integratedwebsystems.com/2012/04/install-mono-2-11/ 现在我想在这个 Mono 实例上运行我的 ASP.NET 站点。我使用 VS 2010 中的“Internet 站点”模板创建了一个空的 MVC 4 站点,并将其发布到运行 Mono 的 Linux 机器上。

我已按照这些说明 (http://www.integratedwebsystems.com/2011/06/get-mvc3-razor-running-on-mono/) 成功通过 xsp4 运行它,以便在运行 xsp4 之前设置环境变量。它可以正常工作(我看到一些新功能,例如 CSS 捆绑,不起作用,但我稍后会处理)。

现在,我想使用像 apache 或 nginx 这样的生产服务器。然而,这似乎几乎是不可能的,而且似乎我不是唯一一个遇到这个问题的人。例如,使用这个简单的 nginx 配置

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;
    }
}

导致 502 Bad Gateway 错误,并且日志文件显示“上游发送了意外的 FastCGI 记录:3 在从上游读取响应标头时”。至于 Apache + mod_mono_server4,我没有移过去的错误

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 

有很多关于这个主题的帖子,甚至在 Stackoverflow 上,但没有真正的答案。但是,一些用户确实报告说他们成功地使用这些服务器在单声道上运行 MVC4 站点,所以我想知道是否有人愿意分享他们的配置设置或分步说明?

【问题讨论】:

    标签: asp.net apache mono nginx


    【解决方案1】:

    安装包将一些文件放置在错误的位置。对于 Apache,您必须将文件 mod-mono-server4.exe 从 /usr/lib/mono/4.0 移动到 /usr/lib/mono/4.5 并更新文件 /usr/bin/mod- 中的引用单服务器4。

    如果您使用的是 XSP 或 FastCgi,则需要对 xsp4.exe 和 fastcgi-mono-server4.exe 以及它们各自在 /usr/bin 中的引用进行相同的处理。

    (我开始后悔自己走上了这条 Mono 之路……)

    【讨论】:

      【解决方案2】:

      这是一个script,它解决了我的 Mono 3.0.3/MVC 3/Nginx 问题。复制所需文件后,网站正常运行。

      【讨论】:

        【解决方案3】:

        你需要知道mono服务器监听哪个端口,并在你的Nginx配置文件中设置fastcgi_pass。

        【讨论】:

          【解决方案4】:

          我不是这方面的专家,但以下 nginx 配置在稍微不同的配置中适用于我(nginx + mono 2.10 + F# + websharper):

          server {
              listen   80;
              access_log   /var/log/myapp/access.log;
          
              location / {
                      root /opt/myapp;
                      index index.html index.htm default.aspx Default.aspx;
                      fastcgi_pass unix:/var/run/myapp/fastcgisocket;
                      include /etc/nginx/fastcgi_params;
              }
          }
          

          当然,fastcgi-mono-server 必须配置为使用套接字 /var/run/myapp/fastcgisocket。

          请注意,您必须注意此套接字的 r/w 权限。

          我仍然有 nginx 不会发送多个请求以与 fastcgi-mono-server 并行处理的问题,但除此之外它工作得很好。

          希望对你有帮助。

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2011-10-26
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2014-11-05
            • 2016-05-31
            相关资源
            最近更新 更多