|
| 1 | +# Building on CentOS 7 |
| 2 | + |
| 3 | +This documents step by step on how to compile and put into use the software `mod_tile` and `renderd`. |
| 4 | +Please see our [Continous Integration script](../../.github/workflows/build-and-test-centos-7.yml) for more detail. |
| 5 | + |
| 6 | +As `CentOS 7` does not provide any `mapnik`/`mapnik-devel` packages in the official repository (nor are any available from `EPEL`,) it must therefore be built and installed before `mod_tile` can be built. Although `boost-devel` is present in the official repository, the version available there (`1.53.0`) is not in [mapnik's recommended dependency list](https://github.com/mapnik/mapnik/blob/v3.0.24/INSTALL.md#depends), so the `boost169-devel` package from `EPEL` should probably be used instead. |
| 7 | + |
| 8 | +```shell |
| 9 | +#!/usr/bin/env bash |
| 10 | +export LD_LIBRARY_PATH=/usr/local/lib |
| 11 | +export MAPNIK_VERSION=3.0.24 |
| 12 | + |
| 13 | +# Install `EPEL` yum repository |
| 14 | +sudo yum --assumeyes install epel-release |
| 15 | + |
| 16 | +# Update installed packages |
| 17 | +sudo yum --assumeyes update |
| 18 | + |
| 19 | +# Install "Development Tools" group |
| 20 | +sudo yum --assumeyes groups install \ |
| 21 | + "Development Tools" |
| 22 | + |
| 23 | +# Install build dependencies |
| 24 | +sudo yum --assumeyes install \ |
| 25 | + boost169-devel \ |
| 26 | + cairo-devel \ |
| 27 | + freetype-devel \ |
| 28 | + gdal-devel \ |
| 29 | + glib2-devel \ |
| 30 | + harfbuzz-devel \ |
| 31 | + httpd-devel \ |
| 32 | + iniparser-devel \ |
| 33 | + libcurl-devel \ |
| 34 | + libicu-devel \ |
| 35 | + libjpeg-turbo-devel \ |
| 36 | + libmemcached-devel \ |
| 37 | + libpng-devel \ |
| 38 | + librados2-devel \ |
| 39 | + libtiff-devel \ |
| 40 | + libwebp-devel \ |
| 41 | + libxml2-devel \ |
| 42 | + postgresql-devel \ |
| 43 | + proj-devel \ |
| 44 | + sqlite-devel \ |
| 45 | + zlib-devel |
| 46 | + |
| 47 | +# Export `GDAL_DATA` & `PROJ_LIB` variables and create directories (if needed) |
| 48 | +export GDAL_DATA=$(gdal-config --datadir) |
| 49 | +export PROJ_LIB=/usr/share/proj |
| 50 | +sudo --preserve-env mkdir -p ${GDAL_DATA} ${PROJ_LIB} |
| 51 | + |
| 52 | +# Download, Build & Install `Mapnik` |
| 53 | +sudo mkdir -p /usr/local/src/mapnik-${MAPNIK_VERSION} |
| 54 | +cd /usr/local/src/mapnik-${MAPNIK_VERSION} |
| 55 | +sudo curl --silent --location https://github.com/mapnik/mapnik/releases/download/v${MAPNIK_VERSION}/mapnik-v${MAPNIK_VERSION}.tar.bz2 \ |
| 56 | + | sudo tar --verbose --extract --bzip2 --strip-components=1 --file=- |
| 57 | +sudo --preserve-env ./configure BOOST_INCLUDES=/usr/include/boost169 BOOST_LIBS=/usr/lib64/boost169 |
| 58 | +sudo --preserve-env JOBS=$(nproc) make |
| 59 | +sudo --preserve-env make install |
| 60 | + |
| 61 | +# Fix issue with `iniparser.h` from `iniparser-devel` not being in the expected location |
| 62 | +sudo mkdir /usr/include/iniparser |
| 63 | +sudo ln -s /usr/include/iniparser.h /usr/include/iniparser/iniparser.h |
| 64 | + |
| 65 | +# Download and build |
| 66 | +sudo git clone https://github.com/openstreetmap/mod_tile.git /usr/local/src/mod_tile |
| 67 | +cd /usr/local/src/mod_tile |
| 68 | +sudo --preserve-env ./autogen.sh |
| 69 | +sudo --preserve-env ./configure |
| 70 | +sudo --preserve-env make |
| 71 | + |
| 72 | +# Create tiles directory |
| 73 | +sudo mkdir --parents /run/renderd /var/cache/renderd/tiles |
| 74 | + |
| 75 | +# Move files of example map |
| 76 | +sudo cp -r "utils/example-map" /var/www/example-map |
| 77 | + |
| 78 | +# Install leaflet |
| 79 | +sudo curl --silent \ |
| 80 | + "https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/leaflet.js" \ |
| 81 | + > /var/www/example-map/leaflet/leaflet.min.js |
| 82 | +sudo curl --silent \ |
| 83 | + "https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/leaflet.css" \ |
| 84 | + > /var/www/example-map/leaflet/leaflet.css |
| 85 | + |
| 86 | +# Add configuration |
| 87 | +sudo cp "etc/renderd/renderd.conf.examples" /etc/renderd.conf |
| 88 | +sudo cp "etc/apache2/renderd.conf" /etc/httpd/conf.d/renderd.conf |
| 89 | +sudo cp "apache2/renderd-example-map.conf" \ |
| 90 | + /etc/httpd/conf.d/renderd-example-map.conf |
| 91 | + |
| 92 | +# Apply CentOS specific changes to configuration files |
| 93 | +sudo sed --in-place \ |
| 94 | + "s#/usr/lib/mapnik/3.0/input#/usr/lib64/mapnik/input#g" \ |
| 95 | + /etc/renderd.conf |
| 96 | +sudo sed --in-place \ |
| 97 | + "s#/usr/share/fonts/truetype#/usr/share/fonts#g" \ |
| 98 | + /etc/renderd.conf |
| 99 | + |
| 100 | +# Add and activate mod_tile for Apache |
| 101 | +echo "LoadModule tile_module /usr/lib64/httpd/modules/mod_tile.so" \ |
| 102 | + | sudo tee --append /etc/httpd/conf.modules.d/11-mod_tile.conf |
| 103 | + |
| 104 | +# Make example map the new main page of Apache |
| 105 | +sudo rm --force /etc/httpd/conf.d/welcome.conf |
| 106 | + |
| 107 | +# Install software |
| 108 | +sudo make install |
| 109 | +sudo make install-mod_tile |
| 110 | + |
| 111 | +# Start services |
| 112 | +sudo httpd |
| 113 | +sudo renderd -f |
| 114 | +``` |
| 115 | + |
| 116 | +Then you can visit: `http://localhost/example-map` |
0 commit comments