Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidheyman/5417b515b421a99360ca to your computer and use it in GitHub Desktop.
Save davidheyman/5417b515b421a99360ca to your computer and use it in GitHub Desktop.
# install epel repo
sudo yum -y install wget
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo rpm -Uvh epel-release-latest-7.noarch.rpm
wget http://yum.postgresql.org/9.3/redhat/rhel-7-x86_64/pgdg-redhat93-9.3-1.noarch.rpm
sudo rpm -Uvh pgdg*.rpm
# update (again)
sudo yum -y update
# install deps
sudo yum -y install make gcc47 gcc-c++ bzip2-devel libpng-devel libtiff-devel zlib-devel libjpeg-devel libxml2-devel python-setuptools git-all python-nose python-devel python proj-devel proj proj-epsg proj-nad freetype-devel freetype libicu-devel libicu git bzip2
# install optional deps
sudo yum -y install gdal-devel gdal postgresql-devel sqlite-devel sqlite libcurl-devel libcurl cairo-devel cairo pycairo-devel pycairo postgresql93 postgresql93-server postgresql93-libs postgresql93-contrib postgresql93-devel postgis2_93 vim
JOBS=`grep -c ^processor /proc/cpuinfo`
# build recent boost
export BOOST_VERSION="1_55_0"
export S3_BASE="http://mapnik.s3.amazonaws.com/deps"
curl -O ${S3_BASE}/boost_${BOOST_VERSION}.tar.bz2
tar xf boost_${BOOST_VERSION}.tar.bz2
cd boost_${BOOST_VERSION}
./bootstrap.sh
./b2 -d1 -j${JOBS} \
--with-thread \
--with-filesystem \
--with-python \
--with-regex -sHAVE_ICU=1 \
--with-program_options \
--with-system \
link=shared \
release \
toolset=gcc \
stage
sudo ./b2 -j${JOBS} \
--with-thread \
--with-filesystem \
--with-python \
--with-regex -sHAVE_ICU=1 \
--with-program_options \
--with-system \
toolset=gcc \
link=shared \
release \
install
cd ../
# set up support for libraries installed in /usr/local/lib
sudo bash -c "echo '/usr/local/lib' > /etc/ld.so.conf.d/boost.conf"
sudo ldconfig
# mapnik
# stable branch: 2.3.x
git clone https://github.com/mapnik/mapnik -b 2.3.x
cd mapnik
./configure
make
make test
sudo make install
cd ../
# node
NODE_VERSION="0.10.26"
wget http://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}.tar.gz
tar xf node-v${NODE_VERSION}.tar.gz
cd node-v${NODE_VERSION}
./configure
make -j${JOBS}
sudo make install
cd ../
# install protobuf libs needed by node-mapnik
sudo yum -y install protobuf-devel protobuf-lite
# Then workaround package bugs:
# 1) 'pkg-config protobuf --libs-only-L' misses -L/usr/lib64
# do this to fix:
export LDFLAGS="-L/usr/lib64"
# 2) '/usr/lib64/libprotobuf-lite.so' symlink is missing
# do this to fix:
sudo ln -s /usr/lib64/libprotobuf-lite.so.8 /usr/lib64/libprotobuf-lite.so
# otherwise you will hit: '/usr/bin/ld: cannot find -lprotobuf-lite' building node-mapnik
# node-mapnik
git clone https://github.com/mapnik/node-mapnik
cd node-mapnik
npm install
npm test
cd ../
# postgis
sudo /usr/pgsql-9.3/bin/postgresql93-setup initdb
sudo service postgresql-9.3 start
@ajhalls
Copy link

ajhalls commented Jul 10, 2018

I get this error in the last section:

npm http 304 https://registry.npmjs.org/nan
npm http 405 https://registry.npmjs.org/mapbox/sphericalmercator
npm ERR! TypeError: Cannot read property 'latest' of undefined
npm ERR!     at next (/usr/local/lib/node_modules/npm/lib/cache.js:744:35)
npm ERR!     at /usr/local/lib/node_modules/npm/lib/cache.js:732:5
npm ERR!     at saved (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/get.js:148:7)
npm ERR!     at /usr/local/lib/node_modules/npm/node_modules/graceful-fs/polyfills.js:133:7
npm ERR!     at Object.oncomplete (fs.js:107:15)
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR!     <http://github.com/npm/npm/issues>

npm ERR! System Linux 3.10.0-693.21.1.el7.x86_64
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! cwd /var/www/maps.reminderdental.com/node-mapnik
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3
npm ERR! type non_object_property_load
npm http 200 https://registry.npmjs.org/aws-sdk/2.0.12
npm http GET https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.0.12.tgz
npm http 200 https://registry.npmjs.org/mapnik-vector-tile/2.1.1
npm http GET https://registry.npmjs.org/mapnik-vector-tile/-/mapnik-vector-tile-2.1.1.tgz
npm http 200 https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.0.12.tgz
npm http 200 https://registry.npmjs.org/mapnik-vector-tile/-/mapnik-vector-tile-2.1.1.tgz
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /var/www/maps.reminderdental.com/node-mapnik/npm-debug.log
npm ERR! not ok code 0

> mapnik@4.0.0 test /var/www/maps.reminderdental.com/node-mapnik
> jshint bin lib/index.js lib/mapnik.js && mocha -R spec --timeout 50000

sh: jshint: command not found
npm ERR! Test failed.  See above for more details.
npm ERR! not ok code 0
sudo: /usr/pgsql-9.3/bin/postgresql93-setup: command not found
Redirecting to /bin/systemctl start postgresql-9.3.service
Failed to start postgresql-9.3.service: Unit not found.
```

@PatriceKast
Copy link

On line 71 if I add the attribute -j${JOBS} to the make, I get an error, because it is expecting a number instead of a string. It seems to work by leaving out the -j attribute and simple call make.

Otherwise I have done everything as described und I get the same error like ajhalls. It seems like the package https://registry.npmjs.org/mapbox/sphericalmercator does no longer exist on the npmjs registry. On this websites it says that the package is depricated and:

This module is now under the @mapbox namespace: install @mapbox/sphericalmercator instead

By executing in shell:
npm install sphericalmercator
it shows, that the source packages can theoretically be found under github.com:mapbox/sphericalmercator. But how can we update the package source in the node-mapnik install file?

Any ideas / help is very appreciated...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment