Installing PostgreSQL and PostGIS¶
Install PostgreSQL¶
Install the package for configuring the PGDG repository:
sudo yum install http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/pgdg-centos94-9.4-1.noarch.rpm
EPEL repository will provide GDAL packages:
sudo yum install http://mirror.sfo12.us.leaseweb.net/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
Install PostgreSQL, PostGIS and related libs:
sudo yum install -y postgis2_94 postgresql94 postgresql94-server postgresql94-libs postgresql94-contrib \
postgresql94-devel gdal gdal-python geos python-pip python-imaging python-virtualenv python-devel gcc-c++ \
python-psycopg2 libxml2 libxml2-devel libxml2-python libxslt libxslt-devel libxslt-python
Init the DB:
/usr/pgsql-9.4/bin/postgresql94-setup initdb
Enable start on boot:
systemctl enable postgresql-9.4
Start postgres service by hand:
systemctl start postgresql-9.4
To restart or reload the instance, you can use the following commands:
systemctl restart postgresql-9.4
systemctl reload postgresql-9.4
Setting PostgreSQL access¶
Now we are going to change user access policy for local connections in file pg_hba.conf::
sudo vim /var/lib/pgsql/9.4/data/pg_hba.conf
Scroll down to the bottom of the document. We only need to edit one line. Change:
# "local" is for Unix domain socket connections only
local all all peer
into:
# "local" is for Unix domain socket connections only
local all all trust
Note
If your PostgreSQL database resides on a separate machine, you have to allow remote access to the databases in the pg_hba.conf for the geonode user and tell PostgreSQL to accept non local connections in your postgresql.conf file
Once the configuration file has been edited, restart PostgreSQL to make these changes effective:
systemctl restart postgresql-9.4
Create GeoNode Users Databases¶
Switch to postgres user:
su postgres
First create the geonode user. GeoNode is going to use this user to access the database::
createuser -P geonode
You will be prompted asked to set a password for the user. Enter geonode as password
Create geonode database with owner geonode:
createdb -O geonode geonode
And database geonode_data with owner geonode:
createdb -O geonode geonode_data
Create PostGIS extension::
psql -d geonode_data -c 'CREATE EXTENSION postgis;'
Then adjust permissions:
psql -d geonode_data -c 'GRANT ALL ON geometry_columns TO PUBLIC;'
psql -d geonode_data -c 'GRANT ALL ON spatial_ref_sys TO PUBLIC;'
And exit postgres user:
exit