个人工具
119.28.94.63
该IP地址的讨论
登录
查看“UbuntuHelp:ModMono”的源代码 - Ubuntu中文
UbuntuHelp
讨论
查看源代码
历史
搜索
导航
首页
最近更改
随机页面
页面分类
帮助
编辑
编辑指南
沙盒
新闻动态
字词处理
工具
链入页面
相关更改
特殊页面
页面信息
查看“UbuntuHelp:ModMono”的源代码
来自Ubuntu中文
←
UbuntuHelp:ModMono
跳转至:
导航
,
搜索
因为以下原因,你没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
{{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, 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 [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>Install the mono development packages: mono-devel </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''' 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> sudo apt-get install libapache2-mod-mono </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: <pre><nowiki> sudo apt-get install mono-apache-server2 </nowiki></pre> '''2) Activate the module:''' <pre><nowiki> sudo a2enmod mod_mono </nowiki></pre> '''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. '''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. The format of these files are explained in the xsp man page. <pre><nowiki> man xsp </nowiki></pre> '''5) Restart apache''' Restart apache so the new configuration is loaded. <pre><nowiki> sudo /etc/init.d/apache2 restart </nowiki></pre> === 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. 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> 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></nowiki></pre> With this configuration, our asp.net application (the aspx files, etc.) would be placed in <code><nowiki>/var/www/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>: <pre><nowiki> <apps> <web-application> <name>MOO!!</name> <vpath>/moo</vpath> <path>/var/www/example.com/moo</path> <vhost>example.com</vhost> </web-application> </apps></nowiki></pre> Reload apache, and you should be done! === Additional Information === * [http://mono-project.com/Mod_mono Official Documentation] == Troubleshooting == === Standard output has not been redirected or process has not been started === After configuring mod_mono_auto, starting up with the test.aspx page gives the following error: <pre><nowiki> Standard output has not been redirected or process has not been started. Description: HTTP 500. Error processing request. Stack Trace: System.InvalidOperationException: Standard output has not been redirected or process has not been started. at System.Diagnostics.Process.CancelErrorRead () [0x00000] at (wrapper remoting-invoke-with-check) System.Diagnostics.Process:CancelErrorRead () at Mono.CSharp.CSharpCodeCompiler.CompileFromFileBatch (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00000] at Mono.CSharp.CSharpCodeCompiler.CompileAssemblyFromFileBatch (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00000] at System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromFile (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00000] at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath, System.CodeDom.Compiler.CompilerParameters options) [0x00000] at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath) [0x00000] at System.Web.Compilation.BuildManager.BuildAssembly (System.Web.VirtualPath virtualPath) [0x00000] at System.Web.Compilation.BuildManager.GetCompiledType (System.String virtualPath) [0x00000] at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath (System.String virtualPath, System.Type requiredBaseType) [0x00000] at System.Web.UI.PageParser.GetCompiledPageInstance (System.String virtualPath, System.String inputFile, System.Web.HttpContext context) [0x00000] at System.Web.UI.PageHandlerFactory.GetHandler (System.Web.HttpContext context, System.String requestType, System.String url, System.String path) [0x00000] at System.Web.HttpApplication.GetHandler (System.Web.HttpContext context, System.String url, Boolean ignoreContextHandler) [0x00000] at System.Web.HttpApplication.GetHandler (System.Web.HttpContext context, System.String url) [0x00000] at System.Web.HttpApplication+<Pipeline>c__Iterator2.MoveNext () [0x00000] </nowiki></pre> The reason may be the lack of gmcs in the path (the Mono C# compiler). With the installation process above you may only get gmcs2. The way to check is to see if you have either one: <pre><nowiki> $ which gmcs </nowiki></pre> If this does not return a location, then you don't have gmcs. Try <pre><nowiki> $ which gmcs2 </nowiki></pre> The best way to resolve the lack of gmcs is to install the mono-devel packages: <pre><nowiki> $ sudo apt-get install mono-devel </nowiki></pre> Restart apache, and navigate back to test.aspx. You should now see the "ASP Test Page" label on the page. [[category:UbuntuHelp]]
该页面使用的模板:
模板:From
(
查看源代码
)
模板:Languages
(
查看源代码
)(受保护)
模板:Languages/Lang
(
查看源代码
)(受保护)
返回至
UbuntuHelp:ModMono
。