繁体   English   中英

单声道2.11与nginx或apache

[英]Mono 2.11 with nginx or apache

我按照这些说明安装了并行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站点,所以我想知道是否有人愿意分享他们的配置设置或分步说明?

安装包将一些文件放在错误的位置。 对于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 3.0.3 / MVC 3 / Nginx问题的脚本 复制完所需文件后,该网站完好无损。

您需要知道哪个端口单声道服务器正在侦听,并在Nginx配置文件中将fastcgi_pass设置为它。

我不是这方面的专家,但以下的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必须配置为使用socket / var / run / myapp / fastcgisocket。

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

我仍然有一个问题,即nginx不会发送多个请求与fastcgi-mono-server并行处理,但除此之外它还可以。

我希望它有所帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM