Gunn Team

Feed Rss

ubuntu10.10下apache2运行ASP.NET

01.19.2011, Linux, by .

Apache and Mono 是在linux上运行.net的最佳组合。
Mono 是一个由Novell 公司主持的项目。该项目的目标是创建一系列符合ECMA 标准(Ecma-334 和Ecma-335)的.NET 工具,包括C# 编译器和共通语言执行平台。与微软的.NET Framework 不同,Mono 项目不仅可以运行于Windows 系统上,还可以运行于Linux,FreeBSD,Unix,Mac OS X 和Solaris。
废话不多说了!我使用的linux是UBUNTU10.10。这里只说在这个系统上是怎么快速搭建好跑.NET的环境的。

首先我的电脑上已经安装好了APACHE。

1) Install packages

sudo aptitude install apache2
sudo aptitude install libapache2-mod-mono
sudo aptitude install mono-apache-server2

2) Activate the module:

sudo a2enmod mod_mono

3) Restart apache:

sudo /etc/init.d/apache2 restart

到这里安装就基本上成功了!
下面是APACHE虚拟主机的配置:

<virtualhost *:80>
  ServerName www.local.com
  ServerAdmin web-admin@www.local.com
  DocumentRoot /srv/www/www.local.com
  # MonoServerPath can be changed to specify which version of ASP.NET is hosted
  # mod-mono-server1 = ASP.NET 1.1 / mod-mono-server2 = ASP.NET 2.0
  # For SUSE Linux Enterprise Mono Extension, uncomment the line below:
  # MonoServerPath www.local.com "/opt/novell/mono/bin/mod-mono-server2"
  # For Mono on openSUSE, uncomment the line below instead:
  MonoServerPath www.local.com "/usr/bin/mod-mono-server2"

  # To obtain line numbers in stack traces you need to do two things:
  # 1) Enable Debug code generation in your page by using the Debug="true"
  #    page directive, or by setting <compilation debug="true" /> in the
  #    application's Web.config
  # 2) Uncomment the MonoDebug true directive below to enable mod_mono debugging
  MonoDebug www.local.com true

  # The MONO_IOMAP environment variable can be configured to provide platform abstraction
  # for file access in Linux.  Valid values for MONO_IOMAP are:
  #    case
  #    drive
  #    all
  # Uncomment the line below to alter file access behavior for the configured application
  MonoSetEnv www.local.com MONO_IOMAP=all
  #
  # Additional environtment variables can be set for this server instance using
  # the MonoSetEnv directive.  MonoSetEnv takes a string of 'name=value' pairs
  # separated by semicolons.  For instance, to enable platform abstraction *and*
  # use Mono's old regular expression interpreter (which is slower, but has a
  # shorter setup time), uncomment the line below instead:
  # MonoSetEnv www.local.com MONO_IOMAP=all;MONO_OLD_RX=1

  MonoApplications www.local.com "/:/srv/www/www.local.com"
  <location "/">
    Allow from all
    Order allow,deny
    MonoSetServerAlias www.local.com
    SetHandler mono
    SetOutputFilter DEFLATE
    SetEnvIfNoCase Request_URI "\.(?:gif|jpe?g|png)$" no-gzip dont-vary
  </location>
  <ifmodule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript
  </ifmodule>
</virtualhost>

提供下index.aspx的测试代码:

< %@ Page Language="C#" %>
< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
  <head>
    <title>ASP Test Page</title>
  </head>
  <body>
        <form id="form1" runat="server">
          <asp:label id="lbl1" runat="server">ASP Test Page</asp:label>
        </form>
  </body>
</html>

参考网址:

http://mono-project.com/Mod_mono

https://help.ubuntu.com/community/ModMono

ubuntu10.10下apache2运行ASP.NET 有1条回应

  1. 现在是测试机器上跑,过几天弄好后,要在NGINX上跑下。
    到时在把NGINX上怎么配置MONO发出来!

    回复

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>