[ms4w-users] How to install FastCGI with ms4w

Alexandre Dubé adube at mapgears.com
Fri Jul 11 16:21:05 EDT 2008


Here's how to install and setup fastCGI with Apache 2.2.8 contained in 
the MS4W 2.2.7 version.

1- MS4W 2.2.7 contains a MapServer compiled to support FastCGI so 
nothing needs to be done there.

2- But, Apache 2.2.8 that comes with MS4W 2.2.7 doesn't include the 
mod_fcgi module.  This module can be dowloaded at 
http://www.apachelounge.com/download/ ... Take the 
mod_fcgid-2.2a-w32.zip which will work with Apache 2.2.8.

3- Copy mod_fcgid.so to your apache/modules folder

4- Install the Visual C++ 2008 Redistributable Package (the binary is 
build with VC 2008).  Download and install, if it isn't already done, 
from:  
www.microsoft.com/downloads/details.aspx?FamilyID=9B2DA534-3E03-4391-8A4D-074B9F2BC1BF&displaylang=en

5- Modify your /ms4w/Apache/conf/httpd.conf

    a) Add :
    LoadModule fcgid_module modules/mod_fcgid.so

    b) Add :
    ScriptAlias /cgi-bin/ "/ms4w/Apache/cgi-bin/"
    ScriptAlias /fcgi-bin/ "/ms4w/Apache/cgi-bin/"

    c) Remove :
    <Directory "/ms4w/Apache/cgi-bin">
        AllowOverride All
        Options None
        Order allow,deny
        Allow from all
    </Directory>

    d) Add :
    <Location "/cgi-bin">
        Options None
        Order allow,deny
        Allow from all
    </Location>

    e) Add :
    <Location "/fcgi-bin">
        # The following line activates the fastCGI script to all files 
in location
        SetHandler fcgid-script
        Options None
        Order allow,deny
        Allow from all
    </Location>

    f) Add :
    <IfModule fcgid_module>
        IPCCommTimeout 60
        IdleTimeout 60
        DefaultMinClassProcessCount 2
        DefaultMaxClassProcessCount 20
        DefaultInitEnv PROJ_LIB    "c:/ms4w/proj/nad/"
        DefaultInitEnv PATH        
"c:/ms4w/Apache/cgi-bin;c:/WINDOWS/system32;c:/WINDOWS;c:/WINDOWS/System32/Wbem;"
        DefaultInitEnv windir      "c:/WINDOWS"
        DefaultInitEnv SystemRoot  "c:/WINDOWS"
        DefaultInitEnv SystemDrive "c:"
        DefaultInitEnv GDAL_DATA   "c:/ms4w/gdaldata"
        DefaultInitEnv GDAL_DRIVER_PATH "c:/ms4w/gdalplugins"
        DefaultInitEnv TMP         "c:/ms4w/tmp"
        DefaultInitEnv TEMP        "c:/ms4w/tmp"
    </IfModule>

6- Restart Apache : /ms4w/apache-restart.bat

7- In your mapfile, set a PROCESSING directive to tell FastCGI to cache 
the connections and layer information on all layers for which connection 
caching is desired - ie. all slow layers.
    a) Add :
    PROCESSING "CLOSE_CONNECTION=DEFER"

8- Now you can load your map using either normal CGI or FastCGI :
    a) CGI :
    http://host:port/cgi-bin/mapserv.exe?...

    b) fastCGI :
    http://host:port/fcgi-bin/mapserv.exe?...

That way, your original cgi-bin folder wont be affected by fastCGI 
unless you use the modified url with "fcti-bin" which is the alias you 
added to your httpd.conf file at 5b).

Special thanks to Jeff McKenna and Daniel Morissette who helped me a lot 
with this.

-- 
Alexandre Dubé
Mapgears
www.mapgears.com


More information about the ms4w-users mailing list