特殊:Badtitle/NS100:ModMono:修订间差异

来自Ubuntu中文
跳到导航跳到搜索
Wikibot留言 | 贡献
无编辑摘要
Wikibot留言 | 贡献
无编辑摘要
第3行: 第3行:
Mod_Mono is an Apache 1.3/2.0/2.2 module that provides ASP.NET support for the web's favorite server, Apache (http://httpd.apache.org).
Mod_Mono is an Apache 1.3/2.0/2.2 module that provides ASP.NET support for the web's favorite server, Apache (http://httpd.apache.org).
== Configuring Mod_Mono on Ubuntu ==
== Configuring Mod_Mono on Ubuntu ==
Ubuntu packages mod_mono very differently than the official distribution.
*The mod_mono packages and configuration on Ubuntu vary depending on the version of Ubuntu.
This guide assumes that you have read the official [https://help.ubuntu.com/ubuntu/serverguide/C/httpd.html Ubuntu Apache 2 Documentation] and understand how ubuntu manages modules and virtual hosts.
*This guide assumes that you have read the official [https://help.ubuntu.com/ubuntu/serverguide/C/httpd.html Ubuntu Apache 2 Documentation] and understand how Ubuntu manages modules and virtual hosts.
*'''Warning: installing mod_mono may uninstall the PHP Apache module. Apparently they cannot co-exist.'''
=== ASP.NET 2.0 AutoHosting on Ubuntu 8.04 Hardy Heron ===
* These instructions are for an [http://mono-project.com/AutoHosting AutoHosting] configuration
* Refer to the [http://mono-project.com/Mod_mono Official Mod_Mono Docs] for a more detailed setup.
<ol><li>Install the mod_mono packages: libapache2-mod-mono mono-apache-server2
</li><li>Enable the Apache module: a2enmod mod_mono_auto
</li><li>Restart Apache: /etc/init.d/apache2 restart</li></ol>
 
To test your setup, you can create a test page with the following content anywhere that Apache can see (i.e. /var/www/test.aspx):
<pre><nowiki>
<%@ 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>
</nowiki></pre>
=== Non-AutoHosting Instructions ===
'''1) Install packages'''
'''1) Install packages'''
To begin, you can easily install mod_mono using apt: ''(universe package sources must be active in /etc/apt/sources.list, see for example [http://www.ubuntux.org/node/71 here])''
To begin, you can easily install mod_mono using apt: ''(universe package sources must be active in /etc/apt/sources.list, see for example [http://www.ubuntux.org/node/71 here])''

2009年5月12日 (二) 17:53的版本

{{#ifexist: :ModMono/zh | | {{#ifexist: ModMono/zh | | {{#ifeq: {{#titleparts:ModMono|1|-1|}} | zh | | }} }} }} {{#ifeq: {{#titleparts:ModMono|1|-1|}} | zh | | }}

Mod_Mono is an Apache 1.3/2.0/2.2 module that provides ASP.NET support for the web's favorite server, Apache (http://httpd.apache.org).

Configuring Mod_Mono on Ubuntu

  • The mod_mono packages and configuration on Ubuntu vary depending on the version of Ubuntu.
  • This guide assumes that you have read the official Ubuntu Apache 2 Documentation and understand how Ubuntu manages modules and virtual hosts.
  • Warning: installing mod_mono may uninstall the PHP Apache module. Apparently they cannot co-exist.

ASP.NET 2.0 AutoHosting on Ubuntu 8.04 Hardy Heron

  1. Install the mod_mono packages: libapache2-mod-mono mono-apache-server2
  2. Enable the Apache module: a2enmod mod_mono_auto
  3. Restart Apache: /etc/init.d/apache2 restart

To test your setup, you can create a test page with the following content anywhere that Apache can see (i.e. /var/www/test.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>

Non-AutoHosting Instructions

1) Install packages To begin, you can easily install mod_mono using apt: (universe package sources must be active in /etc/apt/sources.list, see for example here)

sudo apt-get install libapache2-mod-mono

Optionally, if you would like to use ASP.NET 2.0, you need to install an additional package:

sudo apt-get install mono-apache-server2

2) Activate the module:

sudo a2enmod mod_mono

3) Select the ASP.NET version The /etc/apache2/mods-available/mod_mono.conf file controls which version of ASP.NET is to be used. If you would like to use 2.0, and you installed the package as explained above, open this file in a text editor and follow the directions. 4) Configure your web applications Applications are defined in .webapp files, located in either /etc/mono-server/ or /etc/mono-server2/ depending on which version of ASP.NET you are using. The format of these files are explained in the xsp man page.

man xsp

5) Restart apache Restart apache so the new configuration is loaded.

sudo /etc/init.d/apache2 restart

Example Configuration

Say we have an apache vhost example.com and we would like the URL http://example.com/moo to be an ASP.net application. First we declare the apache site configuration in /etc/apache2/sites-available/example.com and enable it. As mentioned earlier, this is explained in the official Ubuntu documentation.

<VirtualHost 1.2.3.4:80>
        ServerName example.com

        DocumentRoot /var/www/example.com/

        <Directory /var/www/example.com/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                Allow from all
                SetHandler mono
                DirectoryIndex index.aspx index.html
        </Directory>
</VirtualHost>

With this configuration, our asp.net application (the aspx files, etc.) would be placed in /var/www/example.com/moo/. Next, you would create a corresponding webapp file. Let's pretend that we are using ASP.NET 1.x, so we are goint to create /etc/mono-server/example.com-moo.webapp:

<apps>
        <web-application>
                <name>MOO!!</name>
                <vpath>/moo</vpath>
                <path>/var/www/example.com/moo</path>
                <vhost>example.com</vhost>
        </web-application>
</apps>

Reload apache, and you should be done!

Additional Information