在Mono 2.8上部署ASP.NET MVC 2

來源:互聯網
上載者:User

Mono 2.8發布:C#4.0和更好的效能,我們知道Mono 2.8對ASP.NET MVC 2的完全支援,下面我們就來測試下在Mono 2.8上部署ASP.NET MVC 2應用程式。我的環境是Opensuse 11.3,通過以下命令部署好Mono 2.8的開發環境,之所以說是開發環境是同時會更新MonoDevelop,支援Mono2.8的程式開發:

zypper addrepo http://ftp.novell.com/pub/mono/download-stable/openSUSE_11.3 mono-stable
zypper refresh --repo mono-stable
zypper dist-upgrade --repo mono-stable

然後啟動MonoDevelop產生一個ASP.NET MVC 2應用程式TestMvc2。

我們使用Apache2 + mod_mono進行部署,設定一個虛擬機器主機:

   1: <VirtualHost *:80>

   2:     ServerAdmin webmaster@dotnetting.com

   3:     ServerName www.dotnetting.com

   4:  

   5:     # DocumentRoot: The directory out of which you will serve your

   6:     # documents. By default, all requests are taken from this directory, but

   7:     # symbolic links and aliases may be used to point to other locations.

   8:     DocumentRoot /srv/www/vhosts/dotnetting/public_html

   9:  

  10:     # if not specified, the global error log is used

  11:     ErrorLog /srv/www/vhosts/dotnetting/logs/error.log

  12:     CustomLog /srv/www/vhosts/dotnetting/logs/access_log combined

  13:  

  14:     # don't loose time with IP address lookups

  15:     HostnameLookups Off

  16:  

  17:     # needed for named virtual hosts

  18:     UseCanonicalName Off

  19:  

  20:     # configures the footer on server-generated documents

  21:     ServerSignature On

  22:  

  23:  

  24:     # Optionally, include *.conf files from /etc/apache2/conf.d/

  25:     #

  26:     # For example, to allow execution of PHP scripts:

  27:     #

  28:     Include /etc/apache2/conf.d/mod_mono.conf

  29:  

  30:     MonoServerPath www.dotnetting.com "/usr/bin/mod-mono-server4"

  31:     MonoDebug www.dotnetting.com true

  32:     MonoSetEnv www.dotnetting.com MONO_IOMAP=all

  33:     MonoApplications www.dotnetting.com "/:/srv/www/vhosts/dotnetting/public_html"

  34:     <Location "/">

  35:       Allow from all

  36:       Order allow,deny

  37:       MonoSetServerAlias www.dotnetting.com

  38:       SetHandler mono

  39:       SetOutputFilter DEFLATE

  40:       SetEnvIfNoCase Request_URI "\.(?:gif|jpg?g|png)$" no-gzip dont-vary

  41:     </Location>

  42:     <IfModule mod_deflate.c>

  43:       AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript

  44:     </IfModule>

  45:  

  46: </VirtualHost>

 

這是一個通用的ASP.NET虛擬機器主機配置,唯一的一行不同就是MonoServerPath上設定的Mvc1還是mvc2,我們這裡設定為mod-mono-server4,如果你沒有修改這個地方,會收到一個錯誤是web.config 的 targetFramework不對。然後把我們產生測試程式拷貝到/srv/www/vhosts/dotnetting/public_html 。

註:Mono2.8已經移除了對.NET 1.1的支援,因此也就不能設定為mod-mono-server1

重啟Apache2

service apache2 restart

通過瀏覽器訪問www.dotnetting.com ,記得在訪問之前在host檔案中佈建網域名的解析。可以看到下面的頁面:

附:個人常用的VIM命令列表

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.