Mono + apache2 = Service Temporarily Unavailable (503)

☆樱花仙子☆ 提交于 2019-12-04 03:25:27

Have you tried the mod_mono AutoConfiguration feature ? This is clearly the best approach with the Apache/Mono/ASP.NET stack. With it, you don't need anymore to define all Mono settings in your virtual host.

Here is my mod_mono.conf file (on Mac OS X 10.7.2 and Linux Ubuntu 11.04, this should be compatible with your Debian distro) :

<IfModule mono_module>
    AddType application/x-asp-net .config .cs .csproj .dll .resources .resx .sln .vb .vbproj
    AddType application/x-asp-net .asax .ascx .ashx .asmx .aspx .axd .browser .licx .master .rem .sitemap .skin .soap .webinfo

    MonoAutoApplication enabled
    MonoDebug false
    MonoServerPath "/usr/bin/mod-mono-server4"
    MonoSetEnv LANG=fr_FR.UTF-8
    MonoUnixSocket "/tmp/.mod_mono"

    <IfModule dir_module>
        DirectoryIndex Default.aspx
    </IfModule>

    <DirectoryMatch "/(bin|App_Code|App_Data|App_GlobalResources|App_LocalResources)/">
        Order deny,allow
        Deny from all
    </DirectoryMatch>

    <Location "/Mono">
        Order deny,allow
        Deny from all
        Allow from 127.0.0.1 ::1
        SetHandler mono-ctrl
    </Location>
</IfModule>

The most important directive is the "MonoAutoApplication" one. And here is a sample virtual host :

<VirtualHost *:80>
    ServerName www.monorules.fr
    DocumentRoot "/Library/WebServer/Documents/MonoRules"
</VirtualHost>

As you can see, the virtual host is reduced to its simplest expression. The settings defined in the mod_mono.conf file are shared by all the virtual hosts.
The only drawback of this solution is that it does not let you restart only one instance of an ASP.NET site (as in Microsoft IIS). If you use the Mono control panel (see "Location" section) to restart the process, all ASP.NET applications are restarted.

If you have installed mod mono correctly and it is enabled in apache2 then the following configuration should work with your virtualhost.

<VirtualHost *:80>
 ServerName myapp.example.com
  ServerAdmin webmaster@example.com
  DirectoryIndex index.html index.aspx
  DocumentRoot /var/www/vhosts/example.com/subdomains/myapp/httpdocs/

AddMonoApplications myapp.example.com "/:/var/www/vhosts/example.com/subdomains/myapp/httpdocs/"
MonoServerPath myapp.example.com "/usr/bin/mod-mono-server2"

<Directory /var/www/vhosts/example.com/subdomains/myapp/httpdocs/>
    MonoSetServerAlias myapp.example.com
    SetHandler mono
    AddHandler mod_mono .aspx .ascx .asax .ashx .config .cs .asmx
     <FilesMatch "\.(gif|jp?g|png|css|ico|xsl|wmv|zip)$">
        SetHandler None
    </FilesMatch>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow, deny
    Allow from all 
    DirectoryIndex index.aspx
</Directory>
</VirtualHost>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!