个人工具

“UbuntuHelp:ModMono”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
(新页面: {{From|https://help.ubuntu.com/community/ModMono}} {{Languages|UbuntuHelp:ModMono}} Mod_Mono is an Apache 1.3/2.0/2.2 module that provides ASP.NET support for the web's favorite server, A...)
 
第2行: 第2行:
 
{{Languages|UbuntuHelp:ModMono}}
 
{{Languages|UbuntuHelp:ModMono}}
 
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.
 
Ubuntu packages mod_mono very differently than the official distribution.
 
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.
 
 
 
'''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])''
 
 
<pre><nowiki>
 
<pre><nowiki>
 
sudo apt-get install libapache2-mod-mono
 
sudo apt-get install libapache2-mod-mono
 
</nowiki></pre>
 
</nowiki></pre>
 
 
Optionally, if you would like to use [http://quickstarts.asp.net/QuickStartv20/aspnet/doc/whatsnew.aspx ASP.NET 2.0], you need to install an additional package:
 
Optionally, if you would like to use [http://quickstarts.asp.net/QuickStartv20/aspnet/doc/whatsnew.aspx ASP.NET 2.0], you need to install an additional package:
 
 
<pre><nowiki>
 
<pre><nowiki>
 
sudo apt-get install mono-apache-server2
 
sudo apt-get install mono-apache-server2
 
</nowiki></pre>
 
</nowiki></pre>
 
 
'''2) Activate the module:'''
 
'''2) Activate the module:'''
 
 
<pre><nowiki>
 
<pre><nowiki>
 
sudo a2enmod mod_mono
 
sudo a2enmod mod_mono
 
</nowiki></pre>
 
</nowiki></pre>
 
 
'''3) Select the ASP.NET version'''
 
'''3) Select the ASP.NET version'''
 
 
The <code><nowiki>/etc/apache2/mods-available/mod_mono.conf</nowiki></code> 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.
 
The <code><nowiki>/etc/apache2/mods-available/mod_mono.conf</nowiki></code> 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'''
 
'''4) Configure your web applications'''
 
 
Applications are defined in ''.webapp'' files, located in either <code><nowiki>/etc/mono-server/</nowiki></code> or <code><nowiki>/etc/mono-server2/</nowiki></code> depending on which version of ASP.NET you are using.
 
Applications are defined in ''.webapp'' files, located in either <code><nowiki>/etc/mono-server/</nowiki></code> or <code><nowiki>/etc/mono-server2/</nowiki></code> depending on which version of ASP.NET you are using.
 
 
The format of these files are explained in the xsp man page.
 
The format of these files are explained in the xsp man page.
 
 
<pre><nowiki>
 
<pre><nowiki>
 
man xsp
 
man xsp
 
</nowiki></pre>
 
</nowiki></pre>
 
 
 
'''5) Restart apache'''
 
'''5) Restart apache'''
 
 
Restart apache so the new configuration is loaded.
 
Restart apache so the new configuration is loaded.
 
 
<pre><nowiki>
 
<pre><nowiki>
 
sudo /etc/init.d/apache2 restart
 
sudo /etc/init.d/apache2 restart
 
</nowiki></pre>
 
</nowiki></pre>
 
 
=== Example Configuration ===
 
=== Example Configuration ===
 
 
Say we have an apache vhost ''example.com'' and we would like the URL <code><nowiki>http://example.com/moo</nowiki></code> to be an ASP.net application.
 
Say we have an apache vhost ''example.com'' and we would like the URL <code><nowiki>http://example.com/moo</nowiki></code> to be an ASP.net application.
 
 
First we declare the apache site configuration in <code><nowiki>/etc/apache2/sites-available/example.com</nowiki></code> and enable it. As mentioned earlier, this is explained in the [https://help.ubuntu.com/ubuntu/serverguide/C/httpd.html official Ubuntu documentation].
 
First we declare the apache site configuration in <code><nowiki>/etc/apache2/sites-available/example.com</nowiki></code> and enable it. As mentioned earlier, this is explained in the [https://help.ubuntu.com/ubuntu/serverguide/C/httpd.html official Ubuntu documentation].
 
 
<pre><nowiki><VirtualHost 1.2.3.4:80>
 
<pre><nowiki><VirtualHost 1.2.3.4:80>
 
ServerName example.com
 
ServerName example.com
 
 
DocumentRoot /var/www/example.com/
 
DocumentRoot /var/www/example.com/
 
 
<Directory /var/www/example.com/>
 
<Directory /var/www/example.com/>
 
Options Indexes FollowSymLinks MultiViews
 
Options Indexes FollowSymLinks MultiViews
第72行: 第46行:
 
</Directory>
 
</Directory>
 
</VirtualHost></nowiki></pre>
 
</VirtualHost></nowiki></pre>
 
 
With this configuration, our asp.net application (the aspx files, etc.) would be placed in <code><nowiki>/var/example.com/moo/</nowiki></code>.
 
With this configuration, our asp.net application (the aspx files, etc.) would be placed in <code><nowiki>/var/example.com/moo/</nowiki></code>.
 
 
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 <code><nowiki>/etc/mono-server/example.com-moo.webapp</nowiki></code>:
 
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 <code><nowiki>/etc/mono-server/example.com-moo.webapp</nowiki></code>:
 
 
<pre><nowiki><apps>
 
<pre><nowiki><apps>
 
<web-application>
 
<web-application>
第85行: 第56行:
 
</web-application>
 
</web-application>
 
</apps></nowiki></pre>
 
</apps></nowiki></pre>
 
 
Reload apache, and you should be done!
 
Reload apache, and you should be done!
 
 
=== Additional Information ===
 
=== Additional Information ===
 
 
* [http://mono-project.com/Mod_mono Official Documentation]
 
* [http://mono-project.com/Mod_mono Official Documentation]
  
 
[[category:UbuntuHelp]]
 
[[category:UbuntuHelp]]

2007年11月30日 (五) 20:18的版本

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

Ubuntu packages mod_mono very differently than the official distribution. This guide assumes that you have read the official Ubuntu Apache 2 Documentation and understand how ubuntu manages modules and virtual hosts. 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/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