Skip to content

Instantly share code, notes, and snippets.

@vallettea
Last active December 26, 2015 13:09
Show Gist options
  • Save vallettea/7156679 to your computer and use it in GitHub Desktop.
Save vallettea/7156679 to your computer and use it in GitHub Desktop.
Install postgres + postgis on amazon ec2 ami
sudo yum -y update
sudo ln -sf /usr/share/zoneinfo/Europe/Paris /etc/localtime
sudo yum install -y gcc make gcc-c++
sudo yum -y install readline-devel
sudo yum -y install zlib-devel
wget http://ftp.postgresql.org/pub/source/v9.2.2/postgresql-9.2.2.tar.bz2
bzip2 -d postgresql-9.2.2.tar.bz2
tar -xf postgresql-9.2.2.tar
cd postgresql-9.2.2
./configure
gmake
sudo gmake install
cd contrib/hstore
make
sudo make install
sudo adduser postgres
sudo mkdir /usr/local/pgsql/data
sudo chown postgres /usr/local/pgsql/data
sudo su - postgres
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data -A trust
/usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data >logfile 2>&1 &
/usr/local/pgsql/bin/createdb osm
exit
# if you have an error with "pg_filenode.map" file do a sudo reboot
sed -i 'PATH=/usr/local/pgsql/bin:$PATH' ~/.zshrc
cd /home/ec2-user/
mkdir postgis
cd postgis
wget http://download.osgeo.org/proj/proj-4.8.0.tar.gz
gzip -d proj-4.8.0.tar.gz
tar -xvf proj-4.8.0.tar
cd proj-4.8.0
./configure
make
sudo make install
cd /home/ec2-user/postgis
wget http://download.osgeo.org/geos/geos-3.3.7.tar.bz2
bzip2 -d geos-3.3.7.tar.bz2
tar -xvf geos-3.3.7.tar
cd geos-3.3.7
./configure
make
sudo make install
sudo yum -y install libxml2-devel
cd /home/ec2-user/postgis
wget http://oss.metaparadigm.com/json-c/json-c-0.9.tar.gz
gzip -d json-c-0.9.tar.gz
tar -xvf json-c-0.9.tar
cd json-c-0.9
./configure
make
sudo make install
cd /home/ec2-user/postgis
wget http://download.osgeo.org/gdal/gdal-1.9.2.tar.gz
gzip -d gdal-1.9.2.tar.gz
tar -xvf gdal-1.9.2.tar
cd gdal-1.9.2
./configure
make
sudo make install
sudo su
echo /usr/local/lib >> /etc/ld.so.conf
echo /usr/local/pgsql/lib/ >> /etc/ld.so.conf
exit
sudo ldconfig
cd /home/ec2-user/postgis
wget http://postgis.net/stuff/postgis-2.0.3SVN.tar.gz
gzip -d postgis-2.0.3SVN.tar.gz
tar -xf postgis-2.0.3SVN.tar
cd postgis-2.0.3SVN
./configure --with-pgconfig=/usr/local/pgsql/bin/pg_config --with-raster
make
sudo make install
cd extensions/postgis
make clean
make
sudo make install
cd ..
cd postgis_topology
make clean
make
sudo make install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment