[mapserver-dev] MapCache IIS FastCGI Builds

Seth G sethg at geographika.co.uk
Wed Sep 20 09:19:09 PDT 2017


Hi Sven,

I think I missed your message as it got blocked on the mailing list. 
My notes below are the only details I have on building for Windows. 
There is a MAKE script for previous builds at
https://github.com/gisinternals/buildsystem/blob/master/Makefile#L2986 -
but these don't work with the latest source. 
At some point I'll clean up the notes and send a pull request to the
official docs.

Seth

--
web:http://geographika.co.uk
twitter: @geographika

On Thu, Sep 14, 2017, at 08:51 AM, Sven Schroeter wrote:
> Hi Seth,
> 
> we are using mapcache for some of our customers on Windows (2012 Server
> with ms4w) and I just read your post, that you got running mapcache under
> IIS.
> Is there a documentation how to install it and get it run? Where can I
> find a package that runs stable?
> 
> Thanks
> Sven
> 
> 
> 
> -----Urspr√ľngliche Nachricht-----
> Von: mapserver-dev [mailto:mapserver-dev-bounces at lists.osgeo.org] Im
> Auftrag von Seth G
> Gesendet: Donnerstag, 14. September 2017 01:20
> An: mapserver-dev at lists.osgeo.org
> Betreff: [mapserver-dev] MapCache IIS FastCGI Builds
> 
> Hi list,
> 
> 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"
> 	"-DCMAKE_PREFIX_PATH=C:\MapServerBuild\release-1911-x64"^
> 	 "-DCMAKE_INSTALL_PREFIX=release-1911-x64"
> 	 "-DJPEG_LIBRARY=C:\MapServerBuild\release-1911-x64\lib\libjpeg.lib"^
> 	 "-DFCGI_LIBRARY=C:\MapServerBuild\release-1911-x64\lib\libfcgi.lib"
> 	 "-DAPR_INCLUDE_DIR=D:\GitHub\vcpkg\buildtrees\apr\src\apr-1.6.2\include"^
> 	 "-DAPR_LIBRARY=D:\GitHub\vcpkg\buildtrees\apr\x64-windows-rel\Release\libapr-1.lib"
> 	 "-DAPU_LIBRARY=D:\GitHub\vcpkg\buildtrees\apr-util\x64-windows-rel\libaprutil-1.lib"^
> 	 "-DZLIB_LIBRARY=C:\MapServerBuild\release-1911-x64\lib\zdll.lib"
> 	 "-DWITH_APACHE=OFF" "-DWITH_MAPSERVER=OFF"
> 	 "-DBUILD_SHARED_LIBS=OFF"^
> 	 "-DSQLITE_LIBRARY=D:\GitHub\vcpkg\buildtrees\sqlite3\x64-windows-rel\sqlite3.lib"
> 	 "-DWITH_FCGI=ON" "-DREGEX_DIR=C:\MapServerBuild\regex-0.12"^
> 	 "-DSQLITE_INCLUDE_DIR=D:\GitHub\vcpkg\buildtrees\sqlite3\src\sqlite-amalgamation-3190100"
> 	 
> Followed by:
> 
> 	devenv /rebuild Release mapcache.sln /ProjectConfig
> 	"Release|x64"
>  
> I had to add in the regex dependency as this is part of a new 1.6.0
> feature.    
> 
> Then I added in the required DLLs alongside the built .exe
> 
> 	xcopy /Y C:\MapServerBuild\mapcache\vc17x64\Release\*.dll
> 	C:\MapServer\bin
> 	xcopy /Y C:\MapServerBuild\mapcache\vc17x64\cgi\Release\*.exe
> 	C:\MapServer\bin
> 	xcopy /Y C:\MapServerBuild\mapcache\vc17x64\util\Release\*.exe
> 	C:\MapServer\bin
> 	xcopy /Y
> 	D:\MapServer\release-1800-x64-gdal-mapserver\bin\gdal202.dll
> 	C:\MapServer\bin
> 	xcopy /Y
> 	D:\GitHub\vcpkg\buildtrees\apr\x64-windows-rel\Release\libapr-1.dll
> 	C:\MapServer\bin
> 	xcopy /Y
> 	D:\GitHub\vcpkg\buildtrees\apr-util\x64-windows-rel\libaprutil-1.dll
> 	C:\MapServer\bin
> 
> 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.
> (0x4)." 
> 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:
> 
> 	#ifdef _WIN32
> 	char *update_environ(apr_pool_t *pool, char *key, char **envp)
> 	{
> 		char *value = FCGX_GetParam(key, envp);
> 		char *pair;
> 
> 		// request environment variables are not available in
> 		IIS 
> 		// using getenv so copy them across as getenv is used in
> 		several places
> 		pair = apr_psprintf(pool, "%s=%s", key, value);
> 		_putenv(pair);
> 	}
> 	#endif
> 	
> 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. 
> 
> Regards,
> 
> Seth
> 
> --
> web:http://geographika.co.uk
> twitter: @geographika
> _______________________________________________
> mapserver-dev mailing list
> mapserver-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/mapserver-dev
> 


More information about the mapserver-dev mailing list