Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
mapcache
LoadModule mapcache_module /usr/lib/apache2/modules/mod_mapcache.so
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
LogLevel trace8
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
<IfModule mapcache_module>
<Directory /data/>
Require all granted
</Directory>
MapCacheAlias /mapcache "/data/mapcache.xml"
</IfModule>
</VirtualHost>

####Build

docker build -t mapcache-memcached .

####Run

Run memcached container (not required to reproduce error)

docker run -it -d --name mymemcached  memcached

Run Mapcache linked to Memcached

docker run -it -d -p 8181:80 --link mymemcached:mymemcached --name mapcache-failing  mapcache-memcached

####Enter container and start Apache2 service

docker exec -it mapcache-failing /bin/bash

Inside container do:

service apache2 start

Tail Apache error log and segmentation fault:

tail -f /var/log/apache2/error.log

Go to your browser and test:

http://:8181/mapcache/demo/wms

# MapCache container with Memcached support
#This setup reproduces segmentation fault when using memcached in Mapcache as cache backend
FROM ubuntu:14.04
MAINTAINER Martin Bjærge Jensen, martin@septima.dk
# Set correct environment variables.
ENV HOME /root
ENV TERM=xterm
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update
# Install MapCache
RUN apt-get install -y \
apache2 \
wget \
nano \
cmake \
build-essential
RUN apt-get install -y \
libpng12-dev \
libjpeg62-dev \
libcurl4-gnutls-dev \
apache2-dev \
libpixman-1-dev \
libpcre3-dev
RUN apt-get install -y \
# libgdal-dev \
# libgdal1-dev \
# libgeos-dev \
# libapr1-dev \
# libaprutil1-dev \
libapr-memcache-dev \
apache2-prefork-dev
#release 1.4.0 causes segmentation fault
RUN wget https://github.com/mapserver/mapcache/archive/1.4.0.tar.gz -O mapcache-1.4.0.tar.gz
RUN tar xf mapcache-1.4.0.tar.gz
RUN cd mapcache-1.4.0 && \
mkdir build &&\
cd build && \
cmake .. -DWITH_FCGI=0 -DWITH_SQLITE=0 -DWITH_MEMCACHE=1 -DWITH_OGR=0 -DWITH_GEOS=0 -DWITH_RIAK=0 -DWITH_PCRE=0 && \
make && \
make install
RUN ldconfig
# Enable site
ADD 000-default.conf /etc/apache2/sites-available/000-default.conf
RUN a2ensite 000-default.conf
EXPOSE 80
ADD start.sh /start.sh
RUN chmod 0755 /start.sh
# Add VOLUMEs to allow backup of config, logs and databases
VOLUME ["/data"]
ADD mapcache-default.xml /data/mapcache.xml
USER root
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
CMD ["bash", "start.sh"]
# OR :
# service apache2 start
<mapcache>
<cache name="disk" type="disk">
<base>/tmp</base>
<symlink_blank/>
</cache>
<cache name="memcache" type="memcache">
<server>
<host>mymemcached</host>
<port>11211</port>
</server>
</cache>
<source name="vmap0" type="wms">
<getmap>
<params>
<FORMAT>image/png</FORMAT>
<LAYERS>basic</LAYERS>
</params>
</getmap>
<http>
<url>http://vmap0.tiles.osgeo.org/wms/vmap0</url>
</http>
</source>
<tileset name="test">
<source>vmap0</source>
<cache>memcache</cache>
<grid>WGS84</grid>
<grid>GoogleMapsCompatible</grid>
<format>PNG</format>
<metatile>5 5</metatile>
<metabuffer>10</metabuffer>
<expires>3600</expires>
</tileset>
<default_format>JPEG</default_format>
<service type="wms" enabled="true">
<full_wms>assemble</full_wms>
<resample_mode>bilinear</resample_mode>
<format>JPEG</format>
<maxsize>4096</maxsize>
</service>
<service type="wmts" enabled="true"/>
<service type="tms" enabled="true"/>
<service type="kml" enabled="true"/>
<service type="gmaps" enabled="true"/>
<service type="ve" enabled="true"/>
<service type="mapguide" enabled="true"/>
<service type="demo" enabled="true"/>
<errors>report</errors>
<locker type="disk">
<directory>/tmp</directory>
<timeout>300</timeout>
</locker>
</mapcache>
#!/bin/bash
# Start apache
#/usr/sbin/apache2 -D FOREGROUND
tail -f /var/log/apache2/error.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment