Skip to content

Commit 09c783a

Browse files
authored
Update README.md
1 parent 8dd9608 commit 09c783a

File tree

1 file changed

+79
-42
lines changed

1 file changed

+79
-42
lines changed

README.md

+79-42
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ These instructions will get you install PostGIS and Postgresql96 on your Amazon
1010

1111
```
1212
1. Up and running EC2 instance
13-
2. Login access to the EC2 instance
13+
2. Login access to the EC2 instance using Putty
1414
```
1515

1616
### Installation
@@ -20,15 +20,19 @@ Login to the console and install postgresql, postgresql-devel, and postgresql-li
2020
### PostgreSQL96 installation
2121

2222
```
23+
--Update your system
24+
sudo yum update
25+
26+
--Install PostgreSQL96
2327
sudo yum install postgresql96 postgresql96-server postgresql96-devel postgresql96-contrib postgresql96-docs postgresql96-libs
2428
25-
Initialize database:
29+
--Initialize database:
2630
sudo service postgresql96 initdb
2731
28-
Edit your pg_hba.conf file:
32+
--Edit your pg_hba.conf file:
2933
sudo vim /var/lib/pgsql96/data/pg_hba.conf
3034
31-
Scroll down until you see something like this, by default:
35+
--Scroll down until you see something like this, by default:
3236
3337
# TYPE DATABASE USER ADDRESS METHOD
3438
@@ -39,7 +43,7 @@ host all all 127.0.0.1/32 ident
3943
# IPv6 local connections:
4044
host all all ::1/128 ident
4145
42-
Change it to read like this:
46+
--Change it to read like this:
4347
# TYPE DATABASE USER ADDRESS METHOD
4448
4549
# "local" is for Unix domain socket connections only
@@ -50,89 +54,90 @@ host all other_username 0.0.0.0/0 md5
5054
# IPv6 local connections:
5155
host all all ::1/128 md5
5256
53-
Enter username for each user and associate IPs or make it open to all 0.0.0.0/0
54-
Enter a specific IP X.X.X.X/32 to only allow connection from the exact IP
57+
--Enter username for each user and associate IPs or make it open to all 0.0.0.0/0
58+
--Enter a specific IP X.X.X.X/32 to only allow connection from the exact IP
5559
56-
Now, we need to update PostgreSQL to enable remote connections to the database.
60+
--Now, we need to update PostgreSQL to enable remote connections to the database.
5761
5862
sudo vim /var/lib/pgsql96/data/postgresql.conf
5963
60-
Uncomment line:
64+
--Uncomment line:
6165
#listen_addresses = 'localhost' # what IP address(es) to listen on;
6266
63-
Update that line to enable connections from any IP addresses:
67+
--Update that line to enable connections from any IP addresses:
6468
listen_addresses='*'
6569
66-
Uncomment line:
70+
--Uncomment line:
6771
#port = 5432
6872
69-
To read like this:
73+
--To read like this:
7074
port = 5432
7175
72-
Start the postgresql service:
76+
--Start the postgresql service:
7377
sudo service postgresql start
7478
75-
Log into the postgresql
79+
--Log into the postgresql
7680
7781
sudo su - postgres
7882
psql -U postgres
7983
80-
Add a password for your PostgreSQL admin
84+
--Add a password for your PostgreSQL admin
8185
8286
ALTER USER postgres WITH PASSWORD '$password';
8387
84-
Create user credentials for different users.
85-
Replace username with the username you want. Replace $password with the password you want.
88+
--Create user credentials for different users.
89+
--Replace username with the username you want. Replace $password with the password you want.
8690
CREATE USER username SUPERUSER;
8791
ALTER USER username WITH PASSWORD '$password';
8892
8993
CREATE USER username NOSUPERUSER;
9094
ALTER USER username WITH PASSWORD '$otheruserpassword';
9195
92-
Exit from Postgres with \q. Your setup is complete now and is ready to be connected remotely.
93-
Postgresql96 install done
96+
--Exit from Postgres with \q. Your setup is complete now and is ready to be connected remotely.
97+
--Postgresql96 install done
9498
```
9599
### PostGIS installation
96100

97101
First, we install some build tools and the GEOS and PROJ libraries. Then we install PostGIS. Once installed, we will update our libraries, so the server knows where to find them. Finally, we create a temp database for PostGIS.
98102

99103
```
100-
Install build tools
104+
--Install build tools
101105
sudo yum install gcc make gcc-c++ libtool libxml2-devel
102106
103-
Make a directory for PostGIS
107+
--Make a directory for PostGIS
104108
cd /home/ec2-user/
105109
mkdir postgis
106110
cd postgis
107111
108-
//Install GEOS - 3.7.1
112+
--Install GEOS - 3.7.1
109113
wget http://download.osgeo.org/geos/geos-3.7.1.tar.bz2
110114
tar xjvf geos-3.7.1.tar.bz2
111115
cd geos-3.7.1
112116
./configure
113117
make
114118
sudo make install
115119
116-
//Install PROJ - 6.0.0 and datumgrid-1.7
117-
//Find latest build here - https://proj4.org/install.html#install
118-
//This build requires sqlite3 headers - if the configure does not work
119-
//Install sqlite3 from the website - get the latest version
120-
//Follow this installation - https://www.tutorialspoint.com/sqlite/sqlite_installation.htm
121-
//SQLite3 install
122-
//cd into the folder you want to download
120+
--Install PROJ - 6.0.0 and datumgrid-1.7
121+
--Find latest build here - https://proj4.org/install.html#install
122+
--This build requires sqlite3 headers - if the PROJ configure does not work (see below), install sqlite3 from the website - get the latest version
123+
--Follow this installation - https://www.tutorialspoint.com/sqlite/sqlite_installation.htm
123124
125+
--SQLite3 install
126+
--cd into the folder you want to download
124127
wget https://www.sqlite.org/2019/sqlite-autoconf-3280000.tar.gz
125-
$tar xvfz sqlite-autoconf-3280000.tar.gz
126-
$cd sqlite-autoconf-3280000
127-
$./configure --prefix=/usr/local
128-
$make
129-
$make install
128+
tar xvfz sqlite-autoconf-3280000.tar.gz
129+
cd sqlite-autoconf-3280000
130+
./configure --prefix=/usr/local
131+
make
132+
make install
133+
134+
--set the PKG_CONFIG_PATH to find the sqlite3.pc file
130135
131-
//set the PKG_CONFIG_PATH to find the sqlite3.pc file
132136
export PKG_CONFIG_PATH=/your/path/name
133-
//In my case - export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
134137
135-
//Install PROJ - 6.0.0 and datumgrid-1.7
138+
--In my case - export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
139+
140+
--Install PROJ - 6.0.0 and datumgrid-1.7
136141
cd /home/ec2-user/postgis/
137142
wget http://download.osgeo.org/proj/proj-6.0.0.tar.gz
138143
wget http://download.osgeo.org/proj/proj-datumgrid-1.7.zip
@@ -141,10 +146,11 @@ cd proj-6.0.0/data
141146
unzip ../../proj-datumgrid-1.7.zip
142147
cd ..
143148
./configure
149+
--Follow the steps to install SQLite3 above
144150
make
145151
sudo make install
146152
147-
//Install GDAL - 2.4.1
153+
--Install GDAL - 2.4.1
148154
cd /home/ec2-user/postgis
149155
wget http://download.osgeo.org/gdal/gdal-2.4.1.tar.gz
150156
gzip -d gdal-2.4.1.tar.gz
@@ -154,9 +160,9 @@ cd gdal-2.4.1
154160
make
155161
sudo make install
156162
157-
//Install postgis-2.5.2
158-
//Download the latest tar file from https://postgis.net/source/
159-
//postgis-2.5.2.tar
163+
--Install postgis-2.5.2
164+
--Download the latest tar file from https://postgis.net/source/
165+
--postgis-2.5.2.tar
160166
161167
cd /home/ec2-user/postgis/
162168
wget http://download.osgeo.org/postgis/source/postgis-2.5.2.tar.gz
@@ -166,10 +172,41 @@ cd postgis-2.5.2
166172
make
167173
sudo make install
168174
169-
Create a temporary database to test
175+
--Create a temporary database to test
170176
171177
createdb -U postgres temp_postgis
172178
createlang -U postgres plpgsql temp_postgis
173179
psql -U postgres -d temp_postgis < /usr/share/pgsql96/contrib/postgis-2.5/postgis.sql
174180
psql -U postgres -d temp_postgis < /usr/share/pgsql96/contrib/postgis-2.5/spatial_ref_sys.sql
175181
```
182+
Once everything is installed, open your choice of Postgresql software and login or login via CLI (Command Line Interface).
183+
184+
### Enabling PostGIS
185+
PostGIS is an optional extension that must be enabled in each database you want to use it in before you can use it. Installing the software is just the first step. DO NOT INSTALL it in the database called postgres.
186+
187+
Connect to your database with psql or PgAdmin. Run the following SQL. You need only install the features you want:
188+
189+
190+
```
191+
-- Enable PostGIS (includes raster)
192+
CREATE EXTENSION postgis;
193+
-- Enable Topology
194+
CREATE EXTENSION postgis_topology;
195+
-- Enable PostGIS Advanced 3D
196+
-- and other geoprocessing algorithms
197+
-- sfcgal not available with all distributions
198+
CREATE EXTENSION postgis_sfcgal;
199+
-- fuzzy matching needed for Tiger
200+
CREATE EXTENSION fuzzystrmatch;
201+
-- rule based standardizer
202+
CREATE EXTENSION address_standardizer;
203+
-- example rule data set
204+
CREATE EXTENSION address_standardizer_data_us;
205+
-- Enable US Tiger Geocoder
206+
CREATE EXTENSION postgis_tiger_geocoder;
207+
```
208+
209+
### Sources
210+
[PostgreSQL](https://www.postgresql.org/)
211+
[PostGIS](https://postgis.net/install/)
212+
(http://en.joysword.com/posts/2015/05/configuring_geo_spatial_stack_on_amazon_linux/)

0 commit comments

Comments
 (0)