[mapserver-dev] MapCache IIS FastCGI Builds
sethg at geographika.co.uk
Wed Sep 13 16:19:33 PDT 2017
I've been trying to get the 1.6.0 release of Mapcache working under IIS
as a FastCGI application on Windows 10 x64 (the end result was a
success!). Below are a list of notes and questions in case anyone can
provide any more details on this setup.
I used the SDK from GISInternals for the build with a few additions. The
apr-util and sqlite3 dependencies are missing from this, but could be
added using https://github.com/Microsoft/vcpkg
./vcpkg.exe install apr-util:x64-windows
./vcpkg.exe install sqlite3:x64-windows
The Cmake command was as follows:
C:\MapServerBuild\cmake-3.9.1-win64-x64\bin\cmake ..\ -G "Visual
Studio 15 2017 Win64"
devenv /rebuild Release mapcache.sln /ProjectConfig
I had to add in the regex dependency as this is part of a new 1.6.0
Then I added in the required DLLs alongside the built .exe
xcopy /Y C:\MapServerBuild\mapcache\vc17x64\Release\*.dll
xcopy /Y C:\MapServerBuild\mapcache\vc17x64\cgi\Release\*.exe
xcopy /Y C:\MapServerBuild\mapcache\vc17x64\util\Release\*.exe
To get the mapcache.fcgi.exe working I had to make a few source code
changes (see https://github.com/geographika/mapcache/).
getenv in Linux returns both system environment variables (such as
MAPCACHE_CONFIG_FILE), and individual request variables (such as
QUERY_STRING). In Windows (or at least
when using IIS) getenv doesn't return the request variables. A separate
request environment needs to be queried using FCGX_GetParam.
In addition the printf and fwrite (these are aliases for FastCGI
functions FCGI_fprintf and FCGI_fwrite) functions returned HTTP 500
errors in IIS (further details were "The system cannot open the file.
Changing these to FCGX_FPrintF and FCGX_PutStr and passing in the out
FCGX_Stream got things working again.
A clear downside to these edits is that the program will no longer
function as a CGI/ command line application as the functions are FastCGI
specific. One option is to copy all required variables from the
request environment to the standard one using the function below:
char *update_environ(apr_pool_t *pool, char *key, char **envp)
char *value = FCGX_GetParam(key, envp);
// request environment variables are not available in
// using getenv so copy them across as getenv is used in
pair = apr_psprintf(pool, "%s=%s", key, value);
This still leaves the FCGX_FPrintF and FCGX_PutStr functions. I guess a
series of #ifdef _WIN32 could resolve this, but maybe there is a cleaner
way. I've tried a few times to understand how MapServer achieves
the same thing but it is beyond me at the moment. Anyway it is running
fine now in IIS, and is very fast.
More information about the mapserver-dev