I am a few days new to Linux Ubuntu and am in the process of setting up a PostGIS database to use in GeoDjango.
I am going to post all my commands that I have done so far
these are installed in order:
-------------------------------postgres------------------------
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 -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O - | sudo apt-key add -
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install postgresql postgresql-contrib libpq-dev pgadmin4
sudo apt-get install postgis
-------------------------------geodjango------------------------
sudo apt-get install binutils libproj-dev gdal-bin
sudo apt-get install build-essential
sudo apt-get install gcc g++ clang make
--geos
wget http://download.osgeo.org/geos/geos-3.4.2.tar.bz2
tar xjf geos-3.4.2.tar.bz2
cd geos-3.4.2
export CXX="g++ -std=c++98"
./configure
make
sudo make install
cd ..
--proj 4
wget http://download.osgeo.org/proj/proj-4.9.1.tar.gz
wget http://download.osgeo.org/proj/proj-datumgrid-1.5.tar.gz
tar xzf proj-4.9.1.tar.gz
cd proj-4.9.1/nad
tar xzf ../../proj-datumgrid-1.5.tar.gz
cd ..
./configure
make
sudo make install
cd ..
--gdal
wget http://download.osgeo.org/gdal/2.2.0/gdal-2.2.0.tar.gz
tar xzf gdal-2.2.0.tar.gz
cd gdal-2.2.0
./configure
make
sudo make install
now when I go into pgAdmin 4 and run create extension postgis
i get this error
ERROR: could not load library "/usr/lib/postgresql/10/lib/postgis-2.4.so": /usr/lib/liblwgeom-2.4.so.0: undefined symbol: GEOSVoronoiDiagram
SQL state: XX000
UPDATE
followed the directions in this link https://kitcharoenp.github.io/postgresql/postgis/2018/05/28/set_up_postgreSQL_postgis.html and still got the same error
-
I used this method - kitcharoenp.github.io/postgresql/postgis/2018/05/28/… I think you need to replace lsb_release with boinic > example: apt.postgresql.org/pub/repos/apt bionic-pgdg mainMapperz– Mapperz ♦2018年07月19日 18:41:30 +00:00Commented Jul 19, 2018 at 18:41
-
can you spell it out for me. like what exact command do I need to run? do I need to uninstall postgres and reinstall?ziggy– ziggy2018年07月19日 19:08:14 +00:00Commented Jul 19, 2018 at 19:08
-
reinstalled and got the same error :(ziggy– ziggy2018年07月19日 19:27:17 +00:00Commented Jul 19, 2018 at 19:27
2 Answers 2
If you are in Ubuntu, you can install it from packages!
Instead of compiling them from source, you can just execute this command and all the required packages will be installed.
sudo apt-get install binutils libproj-dev gdal-bin
Here is a complete example on how to set up a database with PostGIS on Ubuntu 18, PostgreSQL 10
$ sudo apt-get update
$ sudo apt-get install -y binutils postgresql postgresql-contrib
# Password for the database
$ sudo su - postgres
$ psql
> CREATE USER myprojectuser WITH PASSWORD 'password';
> CREATE DATABASE myproject OWNER myprojectuser;
> ALTER ROLE myprojectuser SET client_encoding TO 'utf8';
> ALTER ROLE myprojectuser SET default_transaction_isolation TO 'read committed';
> ALTER ROLE myprojectuser SET timezone TO 'UTC';
> GRANT ALL PRIVILEGES ON DATABASE myproject TO myprojectuser;
# Test conection, quit with \q or ctrl+d
$ psql -h localhost -U myprojectuser myproject
# Install
$ sudo apt-get install binutils libproj-dev gdal-bin
# Check package version, searching with command
# sudo apt-cache search postgresql | grep gis
$ sudo apt-get install -y postgis postgresql-10-postgis-2.4 python-psycopg2
$ sudo -u postgres psql -c "CREATE EXTENSION postgis; CREATE EXTENSION postgis_topology;" myproject
Reference: Installing Geospatial libraries: GDAL
The error message points to GEOS,
ERROR: could not load library "/usr/lib/postgresql/10/lib/postgis-2.4.so": /usr/lib/liblwgeom-2.4.so.0: undefined symbol: GEOSVoronoiDiagram
You might have better luck with installing a more recent version of GEOS (see e.g. Error building GEOS on Ubuntu 18.04):
Replace 3.4.2 with 3.6.2 in:
--geos
wget http://download.osgeo.org/geos/geos-3.4.2.tar.bz2
tar xjf geos-3.4.2.tar.bz2
cd geos-3.4.2
export CXX="g++ -std=c++98"
./configure
make
sudo make install
cd ..
-- Update --
With new versions of GEOS, you also don't need the CXX flag, which forces (a quite) old C++ standard. When possible, I'd try to compile the libraries with the same compiler and settings with PostgreSQL.
-
okay, does it matter which one I install first?ziggy– ziggy2018年07月20日 15:15:11 +00:00Commented Jul 20, 2018 at 15:15
-
@ziggy I updated the answer, just realizing that you are not compiling PostGIS. But if you are, you can specify which geos version to use: gis.stackexchange.com/questions/253202tinlyx– tinlyx2018年07月20日 15:32:19 +00:00Commented Jul 20, 2018 at 15:32
-
okay I uninstalled 3.4.2 and reinstalled 3.6.2 and it worked, thank youziggy– ziggy2018年07月20日 15:35:03 +00:00Commented Jul 20, 2018 at 15:35