We'll create our environment, install dependencies and then install PostgreSQL, GDAL, PostGIS, Apache, MapServer, QGIS, et al.
# # Except packages installed with 'apt', we will be installing all of our software in a non-standard location # the root location will be /opt/gis # # create base directories mkdir -p /opt/gis/local cd /opt/gis/local mkdir include lib bin src ### Environment Variables. Put all of the following in /opt/gis/default_profile ### ensure your shell is Bash export LANGUAGE=EN export LANG=EN export EDITOR=/usr/bin/vi export VISUAL=/usr/bin/vi export PAGER=/bin/more export TEMPPATH=/tmp export LC_ALL=en_US.UTF-8 export LC_CTYPE=en_US.UTF-8 export MANPATH=/usr/share/man:/usr/local/man ### Check postgresql version after you install it. v13 is specified here. Change it if necessary export LD_LIBRARY_PATH=/opt/gis/local/lib:/usr/lib:/usr/lib64:/usr/local/lib/:/usr/local/lib64:/usr/lib/x86_64-linux-gnu:/usr/lib/postgresql/13/lib export CPATH=/usr/include:/usr/local/include:/opt/gis/local ### Again, check postgresql version after you install it. v13 is specified here. Change it if necessary export PATH=/opt/gis/local/bin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/lib/postgresql/13/bin export PGCLIENTENCODING=LATIN1 export POSTGIS_GDAL_ENABLED_DRIVERS=ENABLE_ALL export POSTGIS_ENABLE_OUTDB_RASTERS=1 ### end of default_profile # use that environment source /opt/gis/default_profile # ADD NON-STANDARD LIBS to: /etc/ld.so.conf.d/gis.conf # such as /opt/gis/local/lib /usr/lib/x86_64-linux-gnu /usr/lib/postgresql/13/lib # and run lddconfig # make new group addgroup gis # install packages for dependencies sudo apt install git libexpat1 libexpat1-dev libxml2 libxml2-dev libpcre3 libpcre3-dev sqlite3 libsqlite3-dev libcurl4-gnutls-dev libcurl4 curl libtiff5 libtiff-dev libboost1.74-all-dev libmpfr-dev libmpfrc++-dev libgmp3-dev libhdf4-0 libhdf4-dev hdf4-tools libhdf4-dev hdf5-tools libhdf5-103 libhdf5-dev libhdfeos-dev libhdfeos0 libhe5-hdfeos0 libhe5-hdfeos-dev netcdf-bin libnetcdf-dev libnetcdf13 python-pip python3-pip libfreetype6-dev librsvg2-dev librsvg2 libfribidi-dev libfcgi-dev libgif-dev swig apache2 # python install gdal pip3 install gdal pip install gdal # re-source environment for good measure source /opt/gis/default_profile # Let's install lots of software from source cd /opt/gis/local/src # build, install json-c git clone https://github.com/json-c/json-c.git cd json-c mkdir build cd build/ cmake -DCMAKE_INSTALL_PREFIX=/opt/gis/local .. make make test make install ### protobuf-c, check for current version sudo apt install protobuf-compiler libprotoc-dev cd /opt/gis/local/src wget https://github.com/protobuf-c/protobuf-c/releases/download/v1.3.3/protobuf-c-1.3.3.tar.gz tar xzf protobuf-c-1.3.3.tar.gz cd protobuf-c-1.3.3 ./configure --prefix=/opt/gis/local make make install # build, install PROJ 6 cd /opt/gis/local/src wget https://download.osgeo.org/proj/proj-6.3.1.tar.gz tar xaf proj-6.3.1.tar.gz cd proj-6.3.1 ./configure --prefix=/opt/gis/local make make install # build, install SFCGAL & CGAL # CGAL build docs: https://doc.cgal.org/latest/Manual/installation.html # building CGAL cd /opt/gis/local/src wget 'https://github.com/CGAL/cgal/releases/download/v5.2.1/CGAL-5.2.1.tar.xz' tar xaf CGAL-5.2.1.tar.xz cd CGAL-5.2.1 mkdir build cd build cmake -DCGAL_HEADER_ONLY=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/opt/gis/local .. make make install # building SFCGAL cd /opt/gis/local/src wget 'https://gitlab.com/Oslandia/SFCGAL/-/archive/v1.3.10/SFCGAL-v1.3.10.tar.gz' tar xaf SFCGAL-v1.3.10.tar.gz cd SFCGAL-v1.3.10 mkdir build cd build cmake -DCMAKE_INSTALL_PREFIX=/opt/gis/local .. make install # build, install GEOS cd /opt/gis/local/src git clone https://github.com/libgeos/geos.git cd geos mkdir build cd build cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/opt/gis/local .. make make test make install # ...and re-source environment again for good measure source /opt/gis/default_profile cd /opt/gis/local/src # PostgreSQL, add to package manager, build, install sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - sudo apt update # installing v13, could be 14 or ? sudo apt install postgresql-13 libpq-dev postgresql-server-dev-13 # ensure lib path exists, change version number and run sudo su - bash ldconfig /usr/lib/postgresql/13/lib ldconfig /opt/gis/local/lib # set up admin user and permissions sudo su - su - postgres psql CREATE USER admin WITH PASSWORD 'securePassword'; create database gisdb; GRANT ALL PRIVILEGES ON DATABASE 'gisdb' to admin; # create readonly permissions create role readonly; GRANT USAGE ON SCHEMA public TO readonly; GRANT SELECT ON ALL TABLES IN SCHEMA public TO readonly; ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readonly; # optionally, add a read only geoserver account to postgres CREATE USER geoserver WITH PASSWORD 'securePassword'; grant readonly to geoserver; # the following will allow OSM hstores in db, very handy! create extension hstore; # Unused, and untested --- FileGDB for gdal, extract sources, use path for --with-fgdb # GDAL can read, but not write .gdb without this. That may be OK, up to you. # https://github.com/Esri/file-geodatabase-api/raw/master/FileGDB_API_1.5/FileGDB_API_1_5_64.tar.gz # ...and again, re-source environment again for good measure source /opt/gis/default_profile # Finally, time to install GDAL, you may want to grab the latest version not 3.2.2 cd /opt/gis/local/src wget 'https://github.com/OSGeo/gdal/releases/download/v3.2.2/gdal-3.2.2.tar.gz' tar xaf gdal-3.2.2.tar.gz cd gdal-3.2.2 ./configure \ --prefix=/opt/gis/local \ --with-xml2=yes \ --with-proj=/opt/gis/local \ --with-libz=internal \ --with-bash-completion=yes \ --with-libtiff=internal \ --with-curl=/bin/curl-config \ --with-pg=yes \ --with-pcraster=internal \ --with-png=internal \ --with-geotiff=internal \ --with-jpeg=internal \ --with-charls \ --with-gif=internal \ --with-hdf4=/usr \ --with-hdf5=/usr/lib/x86_64-linux-gnu/hdf5/serial \ --with-netcdf=/usr/lib/x86_64-linux-gnu \ --with-openjpeg \ --with-expat=yes \ --with-pcre \ --with-geos=yes \ --with-sfcgal=yes \ --with-libjson-c=internal \ --without-pam \ --with-poppler=yes \ --with-perl \ --with-python=yes make make test sudo make install # ...yep, re-source environment again source /opt/gis/default_profile # build, install PostGIS # online docs, install PostGIS: https://postgis.net/docs/postgis_installation.html#install_short_version # you may want to check for a more current version cd /opt/gis/local/src wget 'https://download.osgeo.org/postgis/source/postgis-3.1.1.tar.gz' tar xaf postgis-3.1.1.tar.gz cd postgis-3.1.1 ./configure \ --with-projdir=/opt/gis/local \ --with-jsondir=/opt/gis/local \ --with-protobufdir=/opt/gis/local make sudo make install # as postgres user psql -d gisdb -U postgres CREATE EXTENSION postgis; CREATE EXTENSION postgis_raster; CREATE EXTENSION postgis_sfcgal; --needed for postgis_tiger_geocoder CREATE EXTENSION fuzzystrmatch; --optional used by postgis_tiger_geocoder, or can be used standalone CREATE EXTENSION address_standardizer; CREATE EXTENSION address_standardizer_data_us; CREATE EXTENSION postgis_tiger_geocoder; CREATE EXTENSION postgis_topology; ALTER DATABASE gisdb SET postgis.gdal_enabled_drivers TO 'ENABLE_ALL'; ALTER DATABASE gisdb SET postgis.enable_outdb_rasters = true; # ...you guessed it, re-source environment again source /opt/gis/default_profile # install mapserver cd /opt/gis/src wget https://download.osgeo.org/mapserver/mapserver-7.6.4.tar.gz tar xzf mapserver-7.6.4.tar.gz cd mapserver-7.6.4 mkdir build cd build # full list of options cat ../CMakeLists.txt | grep '^option' | sed 's/^option(//' | sed 's/ \"/\|/' | sed 's/\" /\|/' | sed 's/)$//' | awk -F'|' '{printf("-D%-32s # %s \\\n", $1 "=" $3, $2)}' # make sure our environment is current source /opt/gis/default_profile cmake \ -DCMAKE_INSTALL_PREFIX=/opt/gis/local \ -DWITH_HARFBUZZ=0 \ -DWITH_FRIBIDI=0 \ -DWITH_KML=1 \ -DWITH_SOS=1 \ -DWITH_RSVG=1 \ -DWITH_CLIENT_WMS=1 \ -DWITH_CLIENT_WFS=1 \ -DWITH_CURL=1 \ -DWITH_GIF=1 \ -DWITH_PYTHON=0 \ -DWITH_PHP=0 \ -DWITH_PHPNG=0 \ -DWITH_PERL=0 \ -DWITH_V8=0 \ -DBUILD_STATIC=1 \ -DLINK_STATIC_LIBMAPSERVER=1 \ .. > ../configure.out.txt make sudo make install # enable mapserver with apache change user:group to apache in /etc/apache2/apache.conf, change www-data to apache in group and passwd a2enmod cgi cp /opt/gis/local/bin/mapserv /usr/lib/cgi-bin/local_mapserver #don't use '-' chmod apache:gis /usr/lib/cgi-bin/local_mapserver service apache2 restart # Optionally, install gnuplot 5.4.1 cd /opt/gis/src wget https://sourceforge.net/projects/gnuplot/files/gnuplot/5.4.1/gnuplot-5.4.1.tar.gz tar xzf gnuplot-5.4.1.tar.gz cd gnuplot-5.4.1 apt install libgd-dev ./configure --prefix=/opt/gis/local make make install # OPTIONAL install QGIS cd /opt/gis/src wget -qO - https://qgis.org/downloads/qgis-2020.gpg.key | sudo gpg --no-default-keyring --keyring gnupg-ring:/etc/apt/trusted.gpg.d/qgis-archive.gpg --import sudo chmod a+r /etc/apt/trusted.gpg.d/qgis-archive.gpg apt install gnupg software-properties-common sudo add-apt-repository "deb https://qgis.org/ubuntu $(lsb_release -c -s) main" sudo apt update sudo apt install qgis qgis-plugin-grass Done!
www.Postholer.com © 2005-2024 - W3C - @postholer