您的位置:知识库 » .NET技术

在Mono 2.8上部署ASP.NET MVC 2

作者: geff zhang  来源: 博客园  发布时间: 2010-10-09 17:29  阅读: 1481 次  推荐: 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进行部署,设置一个虚拟主机:

<VirtualHost *:80>
ServerAdmin webmaster@dotnetting.com
ServerName www.dotnetting.com

# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
DocumentRoot /srv/www/vhosts/dotnetting/public_html

# if not specified, the global error log is used
ErrorLog /srv/www/vhosts/dotnetting/logs/error.log
CustomLog /srv/www/vhosts/dotnetting/logs/access_log combined

# don't loose time with IP address lookups
HostnameLookups Off

# needed for named virtual hosts
UseCanonicalName Off

# configures the footer on server-generated documents
 ServerSignature On

# Optionally, include *.conf files from /etc/apache2/conf.d/
# For example, to allow execution of PHP scripts:
Include /etc/apache2/conf.d/mod_mono.conf

MonoServerPath www.dotnetting.com "/usr/bin/mod-mono-server4"
MonoDebug www.dotnetting.com true
MonoSetEnv www.dotnetting.com MONO_IOMAP=all
MonoApplications www.dotnetting.com "/:/srv/www/vhosts/dotnetting/public_html"
<Location "/">
Allow from all
Order allow,deny
MonoSetServerAlias www.dotnetting.com
SetHandler mono
SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI "\.(?:gif|jpg?g|png)$" no-gzip dont-vary
</Location>
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript
</IfModule>
</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命令列表

0
0
标签:MVC Mono

.NET技术热门文章

    .NET技术最新文章

      最新新闻

        热门新闻