Web Server configuration/Apache (Windows)

From PhalangerWiki

Jump to: navigation, search

This text explains how to configure Apache 2.X (2.0, 2.2) to run Phalanger applications on Windows. For Linux see web server configuration on Linux.

Options

Basically there are two options how to run Phalanger applications (and ASP.NET applications in general) on Apache 2.X web server. More precisely two Apache modules that will do the job:

  • mod_mono
  • mod_aspdotnet

We prefer to use the second one (mod_aspdotnet) because this module works as a wrapper of classic Microsoft .NET Framework and nowadays provides more complete set of functionality.

Installation

First, you will ofcourse need the latest Phalanger release installed and Apache web server. Second, you need to install above mentioned mod_aspdotnet module that can be downloaded here.

Configuration

After you have successfully installed Apache web server and "mod_aspdotnet.so" module file which should be located in Apache2.X\modules folder, you have to configure few things in "httpd.conf" configuration file located in Apache2.X\conf folder.

First you have to configure is loading of this module. Find section of httpd.conf where are all LoadModule directives and add following line: (everything else you can add to the end of the "httpd.conf" file)

LoadModule aspdotnet_module modules/mod_aspdotnet.so

Then you have to associate new handler for aspx, php and other type of files:

AddHandler asp.net asax ascx ashx asmx aspx axd config cs csproj \
                   licx rem resources resx soap vb vbproj vsdisco webinfo php 

We need the aspnet_client files to serve the client-side helper scripts:

AliasMatch "^/(?i)aspnet_client/system_web/(\d+)_(\d+)_(\d+)_(\d+)/(.*)" \
           "C:/Windows/Microsoft.NET/Framework/v$1.$2.$3/ASP.NETClientFiles/$4"

<Directory "C:/Windows/Microsoft.NET/Framework/v*/ASP.NETClientFiles">
    Options FollowSymlinks
    Order allow,deny
    Allow from all
</Directory>

For every .NET application (website), you have to use AspNetMount directive which will ensure loading of applications web.config file and other things:

AspNetMount /Phalanger "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/Phalanger"
Alias /Phalanger "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/Phalanger"
<Directory "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/Phalanger">
    Options FollowSymlinks Indexes
    AspNet files
    Order allow,deny
    Allow from all
    DirectoryIndex default.htm index.php
</Directory>

That's it! Now you should be able to use Phalanger (and ASP.NET) on Apache web server. You may need to add some additional configuration, depending on the application you are installing. Also you can find more information in compatibility section. For more information on associating .NET with Apache you can look on official site of the mod_aspdotnet module right here.