[转载]在Mono 2.8上部署ASP.NET MVC 2

[转载]在Mono 2.8上部署ASP.NET MVC 2 – 自由、创新、研究、探索 – 博客园.

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。

image

我们使用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文件中配置域名的解析。可以看到下面的页面:

image

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

作者: 自由、创新、研究、探索……
出处:http://shanyou.cnblogs.com/
版权:本文版权归作者和博客园共有
转载:欢迎转载,为了保存作者的创作热情,请按要求【转载】,谢谢
要求:未经作者同意,必须保留此段声明;必须在文章中给出原文连接;否则必究法律责任
分享到QQ空间
腾讯微博:http://t.qq.com/geffzhang
赞(0) 打赏
分享到: 更多 (0)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏