Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 25 You must be signed in to star a gist
  • Fork 10 You must be signed in to fork a gist
  • Save whyvez/8d19096712ea44ba66b0 to your computer and use it in GitHub Desktop.
Save whyvez/8d19096712ea44ba66b0 to your computer and use it in GitHub Desktop.
postGIS install on AWS linux AMI
#!/bin/bash
#
# Script to setup a Elastic Beanstalk AMI with geospatial libraries and postGIS
#
# sh aws_ami_prep.sh > aws_ami_prep.log 2>&1 &
# Go to ec2-user home directory
cd /home/ec2-user
# yum libraries
sudo yum -y install gcc gcc-c++ make cmake libtool libcurl-devel libxml2-devel rubygems swig fcgi-devel\
libtiff-devel freetype-devel curl-devel libpng-devel giflib-devel libjpeg-devel\
cairo-devel freetype-devel readline-devel openssl-devel python27 python27-devel
# Postgres
wget http://ftp.postgresql.org/pub/source/v9.3.3/postgresql-9.3.3.tar.gz
tar -zxvf postgresql-9.3.3.tar.gz
cd postgresql-9.3.3
./configure --with-openssl --bindir=/usr/bin
make
sudo make install
cd ..
# PROJ
wget http://download.osgeo.org/proj/proj-4.8.0.tar.gz
tar -zxvf proj-4.8.0.tar.gz
cd proj-4.8.0
./configure
make
sudo make install
cd ..
# GEOS
wget http://download.osgeo.org/geos/geos-3.4.2.tar.bz2
tar -xvf geos-3.4.2.tar.bz2
cd geos-3.4.2
./configure
make
sudo make install
cd ..
# GDAL
wget http://download.osgeo.org/gdal/1.10.1/gdal-1.10.1.tar.gz
tar -zxvf gdal-1.10.1.tar.gz
cd gdal-1.10.1
./configure
make
sudo make install
cd ..
# PostGIS
export LD_LIBRARY_PATH=/usr/local/pgsql/lib/:LD_LIBRARY_PATH
wget http://download.osgeo.org/postgis/source/postgis-2.1.0.tar.gz
tar -xvf postgis-2.1.0.tar.gz
cd postgis-2.1.0
./configure
make
sudo make install
cd ..
@vladborovtsov
Copy link

thanks so much!

@smber1
Copy link

smber1 commented Apr 25, 2016

You sir, rock!

@jesign
Copy link

jesign commented Jun 15, 2018

getting this error:

psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

@sgibbes
Copy link

sgibbes commented Jun 21, 2019

Thank you, this is very helpful! I followed other's instructions and couldn't get it to work before I tried your solution. Now that I have multiple installs of postgres, I think I'm messing up the postgis. If I start fresh with your instructions, how do I initiate the database? I tried psql -U postgres but does not work. Thanks!

@DharmendraRathor
Copy link

I am using "Amazon Linux 2 AMI" for EC2 instance and followed the steps mentioned in link. I get following error at step at make step while installing "geos-3.4.2.tar.bz2" . "#error "Can not compile without isnan function or macro" . Tried with latest version of geos, but same error . Any one face similar issue ?

@sgibbes
Copy link

sgibbes commented Sep 19, 2019

I stopped trying this as a solution, too much of a headache. Instead, I am using docker, so easy!

@sklarsa
Copy link

sklarsa commented Mar 7, 2020

@DharmendraRathor I had the same problem on AWS Linux 2 AMI. No problems with the earlier version of the AMI though

@SimonRichartz
Copy link

@DharmendraRathor @sklarsa ran into the same error. Found that a previous beta version of GEOS doesn't throw that eror

wget http://download.osgeo.org/geos/geos-3.7.0beta1.tar.bz2
tar -xvf geos-3.7.0beta1.tar.bz2
cd geos-3.7.0beta1/
./configure
make
sudo make install
cd ..
rm -rvf geos-3.7.0beta1.tar.bz2

@SaulOviedo
Copy link

Hii @SimonRichartz, I'm having a hard time to get postgis working on a ec2 (AMI) machine. is that the only change you made? can I see your script? thanks

@enthusiastics
Copy link

What shall I do if I used PostgreSQL13

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