Trouble installing mod_mono on Mac OSX Lion

我怕爱的太早我们不能终老 提交于 2019-12-06 16:07:33

Here is what I did to set up mono/mod_mono on OSX 10.7, Apache2 - hopefully it saves someone else a few steps.

Note that I used a separate install of apache2. Your mileage may vary, but I have found pieces of installs here and there that are aggregated here as of Jul 2012 ... By configuring mod_mono.conf as I have, I now have an apache2/mono install that works, with an apache2 install that is standard from apache.org. While I am an Apple fan boy, I wish the OSX Apache installations were in a little more standard form.

(1) Set up Apache2 on OSX or use the default implementation as per your preference. If you build the httpd engine yourself, see commentary below. (2) Get mod_mono source, and compile as shown below. (3) Configure Apache's httpd.conf to include mod_mono.conf. (4) Edit the mod_mono.conf to fit your needs. (5) Restart Apache2.

When building apache2 to be placed at /usr/local/apache2: ./configure --prefix=/usr/local/apache2 --with-included-apr --enable-mods-shared=all --enable-module=so --enable-authz-host

When building mod_mono to find apache2 at /usr/local/apache2: ./configure --prefix=/usr/local

When configuring mod_mono on OSX 10.7 assuming that mono is accessible through /usr/bin as with a macports mono install:

# mod_mono.conf

# Achtung! This file may be overwritten
# Use 'include mod_mono.conf' from other configuration file
# to load mod_mono module.

<IfModule !mod_mono.c>
    LoadModule mono_module /usr/local/apache2/modules/mod_mono.so
</IfModule>

<IfModule mod_headers.c>
    Header set X-Powered-By "Mono"
</IfModule>

AddType application/x-asp-net .aspx
AddType application/x-asp-net .asmx
AddType application/x-asp-net .ashx
AddType application/x-asp-net .asax
AddType application/x-asp-net .ascx
AddType application/x-asp-net .soap
AddType application/x-asp-net .rem
AddType application/x-asp-net .axd
AddType application/x-asp-net .cs
AddType application/x-asp-net .vb
AddType application/x-asp-net .master
AddType application/x-asp-net .sitemap
AddType application/x-asp-net .resources
AddType application/x-asp-net .skin
AddType application/x-asp-net .browser
AddType application/x-asp-net .webinfo
AddType application/x-asp-net .resx
AddType application/x-asp-net .licx
AddType application/x-asp-net .csproj
AddType application/x-asp-net .vbproj
AddType application/x-asp-net .config
AddType application/x-asp-net .Config
AddType application/x-asp-net .dll
DirectoryIndex index.aspx
DirectoryIndex Default.aspx
DirectoryIndex default.aspx

Alias /mono "/Users/tommy/Sites/mono"
AddMonoApplications default "/mono:/Users/tommy/Sites/mono"
MonoServerPath **default** "/usr/bin/mod-mono-server4"
MonoExecutablePath "/usr/bin/mono"

<Location /mono>
      MonoSetServerAlias **default**
      SetHandler mono
      DirectoryIndex index.aspx
</Location>

Note that the httpd.conf file includes the mod_mono.conf file shown above.

CedX

64-bit Mono VM is not required in order to run the 64-bit mod_mono under Apache. See my own "file" command outputs (I'm on Lion 10.7.2 with Apache 2.2.20, Mono 2.10.8 and mod_mono 2.10) :

file /usr/bin/mono
/usr/bin/mono: Mach-O executable i386

file /usr/libexec/apache2/mod_mono.so
/usr/libexec/apache2/mod_mono.so: Mach-O 64-bit bundle x86_64

file /usr/sbin/httpd
/usr/sbin/httpd: Mach-O universal binary with 2 architectures
/usr/sbin/httpd (for architecture x86_64):  Mach-O 64-bit executable x86_64
/usr/sbin/httpd (for architecture i386):    Mach-O executable i386

So, I have exactly the same output as you, and as you can see you must use a 64-bit mod_mono in order to run ASP.NET pages under 64-bit Apache with a 32-bit Mono VM.

I think you should try again from the beginning:

  • download the latest Mono VM (I suggest you to take version 2.10.8, not 2.10.8.1 as this one is not considered stable)
  • uninstall all previous versions of Mono by running in command line the script uninstallMono.sh located in the MonoFramework-MRE-2.10.8_3.macos10.xamarin.x86.pkg bundle, under the directory Contents/Resources
  • install normally the Mono VM
  • download the latest mod_mono Apache module : you must ensure that mod_mono version matches Mono VM version
  • extract the content of the archive where you want and compile it with the following commands (as you can see I don't provide any argument to the commands):

    ./configure
    make
    sudo make install

  • ensure that you have the following line at the end of your /etc/apache2/httpd.conf file : Include /private/etc/apache2/mod_mono.conf

  • restart Apache server with the following command: sudo apachectl restart

This should work! If it's not the case, please post the output of mod_mono compilation to see if any error occurred. And also your httpd.conf file: the problem may be related to another Apache module that conflicts with mod_mono.

I suggest to use my own version of mod_mono.conf file, because it enables the AutoHosting feature (just replace the MonoSetEnv LANG=fr_FR.UTF-8 line with your current culture, like "en-US.UTF-8" or "ja-JP.UTF-8").

Good luck! :o)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!