2012-10-18 42 views
5

我已經按照以下說明安裝了並行單聲道(2.11.3):http://www.integratedwebsystems.com/2012/04/install-mono-2-11/現在我想在這個Mono實例上運行我的ASP.NET站點。我在VS 2010中使用「Internet站點」模板創建了一個空的MVC 4站點,並將它發佈到運行Mono的Linux框中。Mono 2.11 with nginx or apache

我已成功通過xsp4按照這些說明運行它(http://www.integratedwebsystems.com/2011/06/get-mvc3-razor-running-on-mono/),以在運行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網關錯誤錯誤,日誌文件說「上游發送意想不到的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 

有不少帖子對這個話題,甚至在這裏的#1,但沒有真正的答案。但是,有些用戶確實報告說他們成功地在這些服務器上運行單聲道MVC4站點,所以我想知道是否有人想分享他們的配置設置或分步指導?

回答

0

您需要知道哪個端口單聲道服務器正在偵聽,並在您的Nginx配置文件中爲其設置fastcgi_pass。

5

安裝包將一些文件放在錯誤的地方。對於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中的相應引用將需要同樣的處理。

(我開始後悔我跟着下來這個單路......)

0

我不是這方面的專家,但以下nginx的配置稍有不同的配置對我的作品(nginx的+單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的單 - 服務器將必須被配置爲使用所述插座的/ var /運行/ MyApp的/ fastcgisocket。

請注意,您必須小心使用此套接字的讀/寫權限。

我仍然有問題,nginx不會發送多個請求與fastcgi-mono-server並行處理,但除此之外它很好。

我希望它有幫助。

1

這是一個解決了我的Mono 3.0.3/MVC 3/Nginx問題的script。複製完所需的文件後,該網站正常運行。