AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 396306
Accepted
fuzzycow101
fuzzycow101
Asked: 2012-06-07 20:02:29 +0800 CST2012-06-07 20:02:29 +0800 CST 2012-06-07 20:02:29 +0800 CST

使用 fastcgi-mono-server4 的 nginx 上的 Mono 2.11 将无法工作

  • 772

我在 centos 6.2 上运行的 nginx 1.0.15 网络服务器设置了 mono 2.11。我从源代码构建它,xps2、xps4 和 fastcgi-mono-server2 按预期工作。问题是当我尝试运行 fastcgi-mono-server4 时。当我跑步时:

fastcgi-mono-server4 /applications=site:/:/srv/www/html/ /socket=tcp:127.0.0.1:9000 /loglevels=Debug /printlog=true

这是我从 fastcgi-mono-server2 得到的:

[2012-06-06 23:51:07Z] Debug   Record received. (Type: BeginRequest, ID: 1, Length: 8)
[2012-06-06 23:51:07Z] Debug   Record received. (Type: Params, ID: 1, Length: 801)
[2012-06-06 23:51:07Z] Debug   Record received. (Type: Params, ID: 1, Length: 0)
[2012-06-06 23:51:07Z] Debug   Read parameter. (QUERY_STRING = )
[2012-06-06 23:51:07Z] Debug   Read parameter. (REQUEST_METHOD = GET)
[2012-06-06 23:51:07Z] Debug   Read parameter. (CONTENT_TYPE = )
[2012-06-06 23:51:07Z] Debug   Read parameter. (CONTENT_LENGTH = )
[2012-06-06 23:51:07Z] Debug   Read parameter. (SCRIPT_NAME = /)
[2012-06-06 23:51:07Z] Debug   Read parameter. (REQUEST_URI = /)
[2012-06-06 23:51:07Z] Debug   Read parameter. (DOCUMENT_URI = /)
[2012-06-06 23:51:07Z] Debug   Read parameter. (DOCUMENT_ROOT = /srv/www/html)
[2012-06-06 23:51:07Z] Debug   Read parameter. (SERVER_PROTOCOL = HTTP/1.1)
[2012-06-06 23:51:07Z] Debug   Read parameter. (GATEWAY_INTERFACE = CGI/1.1)
[2012-06-06 23:51:07Z] Debug   Read parameter. (SERVER_SOFTWARE = nginx/1.0.15)
[2012-06-06 23:51:07Z] Debug   Read parameter. (REMOTE_ADDR = 192.168.128.121)
[2012-06-06 23:51:07Z] Debug   Read parameter. (REMOTE_PORT = 62326)
[2012-06-06 23:51:07Z] Debug   Read parameter. (SERVER_ADDR = 192.168.128.125)
[2012-06-06 23:51:07Z] Debug   Read parameter. (SERVER_PORT = 80)
[2012-06-06 23:51:07Z] Debug   Read parameter. (SERVER_NAME = site)
[2012-06-06 23:51:07Z] Debug   Read parameter. (REDIRECT_STATUS = 200)
[2012-06-06 23:51:07Z] Debug   Read parameter. (PATH_INFO = )
[2012-06-06 23:51:07Z] Debug   Read parameter. (SCRIPT_FILENAME = /srv/www/html/)
[2012-06-06 23:51:07Z] Debug   Read parameter. (HTTP_HOST = site)
[2012-06-06 23:51:07Z] Debug   Read parameter. (HTTP_USER_AGENT = Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20100101 Firefox/13.0)
[2012-06-06 23:51:07Z] Debug   Read parameter. (HTTP_ACCEPT = text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8)
[2012-06-06 23:51:07Z] Debug   Read parameter. (HTTP_ACCEPT_LANGUAGE = en-us,en;q=0.5)
[2012-06-06 23:51:07Z] Debug   Read parameter. (HTTP_ACCEPT_ENCODING = gzip, deflate)
[2012-06-06 23:51:07Z] Debug   Read parameter. (HTTP_CONNECTION = keep-alive)
[2012-06-06 23:51:07Z] Debug   Read parameter. (HTTP_COOKIE = ASP.NET_SessionId=0176BE8FC161E702439D3C91)
[2012-06-06 23:51:07Z] Debug   Record received. (Type: StandardInput, ID: 1, Length: 0)
[2012-06-06 23:51:08Z] Debug   Record sent. (Type: StandardOutput, ID: 1, Length: 196)
[2012-06-06 23:51:08Z] Debug   Record sent. (Type: StandardOutput, ID: 1, Length: 128)
[2012-06-06 23:51:08Z] Debug   Record sent. (Type: StandardOutput, ID: 1, Length: 0)
[2012-06-06 23:51:08Z] Debug   Record sent. (Type: EndRequest, ID: 1, Length: 8)

这就是我从 fastcgi-mono-server4 得到的:

[2012-06-06 23:50:52Z] Debug   Record received. (Type: BeginRequest, ID: 1, Length: 8)
[2012-06-06 23:50:52Z] Debug   Record received. (Type: Params, ID: 1, Length: 801)
[2012-06-06 23:50:52Z] Debug   Record received. (Type: Params, ID: 1, Length: 0)
[2012-06-06 23:50:52Z] Debug   Read parameter. (QUERY_STRING = )
[2012-06-06 23:50:52Z] Debug   Read parameter. (REQUEST_METHOD = GET)
[2012-06-06 23:50:52Z] Debug   Read parameter. (CONTENT_TYPE = )
[2012-06-06 23:50:52Z] Debug   Read parameter. (CONTENT_LENGTH = )
[2012-06-06 23:50:52Z] Debug   Read parameter. (SCRIPT_NAME = /)
[2012-06-06 23:50:52Z] Debug   Read parameter. (REQUEST_URI = /)
[2012-06-06 23:50:52Z] Debug   Read parameter. (DOCUMENT_URI = /)
[2012-06-06 23:50:52Z] Debug   Read parameter. (DOCUMENT_ROOT = /srv/www/html)
[2012-06-06 23:50:52Z] Debug   Read parameter. (SERVER_PROTOCOL = HTTP/1.1)
[2012-06-06 23:50:52Z] Debug   Read parameter. (GATEWAY_INTERFACE = CGI/1.1)
[2012-06-06 23:50:52Z] Debug   Read parameter. (SERVER_SOFTWARE = nginx/1.0.15)
[2012-06-06 23:50:52Z] Debug   Read parameter. (REMOTE_ADDR = 192.168.128.121)
[2012-06-06 23:50:52Z] Debug   Read parameter. (REMOTE_PORT = 62326)
[2012-06-06 23:50:52Z] Debug   Read parameter. (SERVER_ADDR = 192.168.128.125)
[2012-06-06 23:50:52Z] Debug   Read parameter. (SERVER_PORT = 80)
[2012-06-06 23:50:52Z] Debug   Read parameter. (SERVER_NAME = site)
[2012-06-06 23:50:52Z] Debug   Read parameter. (REDIRECT_STATUS = 200)
[2012-06-06 23:50:52Z] Debug   Read parameter. (PATH_INFO = )
[2012-06-06 23:50:52Z] Debug   Read parameter. (SCRIPT_FILENAME = /srv/www/html/)
[2012-06-06 23:50:52Z] Debug   Read parameter. (HTTP_HOST = site)
[2012-06-06 23:50:52Z] Debug   Read parameter. (HTTP_USER_AGENT = Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20100101 Firefox/13.0)
[2012-06-06 23:50:52Z] Debug   Read parameter. (HTTP_ACCEPT = text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8)
[2012-06-06 23:50:52Z] Debug   Read parameter. (HTTP_ACCEPT_LANGUAGE = en-us,en;q=0.5)
[2012-06-06 23:50:52Z] Debug   Read parameter. (HTTP_ACCEPT_ENCODING = gzip, deflate)
[2012-06-06 23:50:52Z] Debug   Read parameter. (HTTP_CONNECTION = keep-alive)
[2012-06-06 23:50:52Z] Debug   Read parameter. (HTTP_COOKIE = ASP.NET_SessionId=0176BE8FC161E702439D3C91)
[2012-06-06 23:50:53Z] Debug   Record received. (Type: StandardInput, ID: 1, Length: 0)
[2012-06-06 23:50:53Z] Debug   Record sent. (Type: EndRequest, ID: 1, Length: 8)

我看不出我做错了什么。任何帮助都会很棒。

编辑:返工,现在我收到错误网关的 502 错误。日志看起来仍然一样。

查看我的 Nginx 错误日志,发现许多这样的条目:

2012/06/18 13:56:01 [error] 3108#0: *4 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.128.121, server: site, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "site"

无论 fastcgi-mono-server4 是否打开,我都会得到相同的响应。它现在总是显示 502 错误。

centos fastcgi nginx mono
  • 1 1 个回答
  • 5042 Views

1 个回答

  • Voted
  1. Best Answer
    zyash
    2012-07-28T06:50:39+08:002012-07-28T06:50:39+08:00

    我的示例 MVC3 应用程序在来自 badgerports.org 的 Mono 2.10.8.1 上运行良好(我使用 ubuntu)。

    从源代码安装 Mono 2.11.2 后,同一个应用程序将始终返回 502 Bad Gateway,就像您的情况一样。

    我的 nginx 日志如下所示:

    [error] 3384#0: *101 upstream sent unexpected FastCGI record: 3 while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost:8000"
    

    在将 printlog 选项设置为 true 的情况下调用 fastcgi-mono-server4 之后

    sudo /opt/mono-2.11.2/bin/fastcgi-mono-server4 /printlog=True /applications=/:/var/www/mono/Mvc3Template /socket=tcp:127.0.0.1:9000
    

    它会在访问 localhost:8000/ 后生成此堆栈跟踪

    [2012-07-27 14:55:57Z] Notice  Beginning to receive records on connection.
    [2012-07-27 14:55:58Z] Error   ERROR PROCESSING REQUEST: System.TypeInitializationException: An exception was thrown by the type initializer for Mono.WebServer.FastCgi.WorkerRequest
    
    Server stack trace: 
      at Mono.WebServer.FastCgi.ApplicationHost.ProcessRequest (Mono.WebServer.FastCgi.Responder responder) [0x00001] in /home/r522/Desktop/mono-2.11.2/build/xsp-2.10.2/src/Mono.WebServer.FastCgi/ApplicationHost.cs:47 
      at (wrapper remoting-invoke-with-check) Mono.WebServer.FastCgi.ApplicationHost:ProcessRequest (Mono.WebServer.FastCgi.Responder)
      at (wrapper xdomain-dispatch) Mono.WebServer.FastCgi.ApplicationHost:ProcessRequest (object,byte[]&,byte[]&)
    
    Exception rethrown at [0]: 
     ---> System.InvalidCastException: Cannot cast from source type to destination type.
      at System.Configuration.ConfigurationManager.get_AppSettings () [0x00000] in <filename unknown>:0 
      at Mono.WebServer.FastCgi.WorkerRequest..cctor () [0x0002c] in /home/r522/Desktop/mono-2.11.2/build/xsp-2.10.2/src/Mono.WebServer.FastCgi/WorkerRequest.cs:50 
      --- End of inner exception stack trace ---
      at (wrapper xdomain-invoke) Mono.WebServer.FastCgi.ApplicationHost:ProcessRequest (Mono.WebServer.FastCgi.Responder)
      at (wrapper remoting-invoke-with-check) Mono.WebServer.FastCgi.ApplicationHost:ProcessRequest (Mono.WebServer.FastCgi.Responder)
      at Mono.WebServer.FastCgi.Responder.Process () [0x00060] in /home/r522/Desktop/mono-2.11.2/build/xsp-2.10.2/src/Mono.WebServer.FastCgi/Responder.cs:90 
    [2012-07-27 14:55:58Z] Notice  Finished receiving records on connection
    

    这是我的一些配置:

    #/etc/nginx/sites-enabled/mono
    
     server {
             listen   8000;
             server_name  localhost;
             access_log   /var/log/nginx/mono.access.log;
             error_log    /var/log/nginx/mono.error.log;
             location / {
                     root /var/www/mono/Mvc3Template;
                     index index.html index.htm default.aspx Default.aspx;
                     fastcgi_index /Home/Index; # Points to HomeController Index Action
                     fastcgi_pass 127.0.0.1:9000;
                     include /etc/nginx/fastcgi_params;
             }
     }
    

    -

    # Directory structure
    /var/www/mono
    ├── Mvc3Template
    │   ├── bin
    │   ├── Content
    │   ├── Controllers
    |   ... omitted rest
    ├── Mvc3Template.sln
    ├── Mvc3Template.suo
    ├── Mvc3Template.userprefs
    ├── packages
    

    -

    我在这里找到了解决我的问题的方法:bugzilla.xamarin.com/show_bug.cgi?id=2876(让我感到困扰的是它应该在 2012 年 2 月得到修复 - 我编译的单声道是在 6 月 afaik 发布的,但它没有开箱即用)

    我根据那里找到的修复单声道安装的建议制作了一个脚本,只需将 PREFIX 变量指向您的单声道目录并运行它:

    #!/bin/bash
    
    # Your mono directory
    PREFIX=/opt/mono-2.11.2
    
    
    FILES=('mod-mono-server4'
           'fastcgi-mono-server4'
           'xsp4')
    
    cd $PREFIX/lib/mono/4.0
    
    for file in "${FILES[@]}"
    do
       cp "$file.exe" ../4.5
    done
    
    
    cd $PREFIX/bin
    
    for file in "${FILES[@]}"
    do
      sed -ie 's|mono/4.0|mono/4.5|g' $file
    done
    

    在此之后,应用程序“工作”了,但还没有完成。它不再是 502,我得到了一个很好的堆栈跟踪...

    System.Web.Compilation.CompilationException
    : at IKVM.Reflection.Reader.ModuleReader.ResolveType (Int32 metadataToken, IGenericContext context) [0x00000] in <filename unknown>:0
    
    Description: Error compiling a resource required to service this request. Review your source file and modify it to fix this error.
    
    Details: : at IKVM.Reflection.Reader.ModuleReader.ResolveType (Int32 metadataToken, IGenericContext context) [0x00000] in <filename unknown>:0
    
    Error origin: Compiler
    
    Error source file: ~/Global.asax
    Exception stack trace:
    

    所以我自己还有一些事情要弄清楚,但我希望这对你有所帮助。

    • 7

相关问题

  • 如何在 Linux 机器上找到有关硬件的详细信息?

  • 使用 crontab 和 /etc/cron.hourly,daily,weekly 的区别

  • 持续监控许多服务器运行状况的简单方法?

  • Hudson 无法在 tomcat5 中启动

  • CentOS 的依赖挑战

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve