Install PostgreSQL + PostGIS with the source code in the Liunx Environment

Source: Internet
Author: User
Tags postgis

Install postgreSQL + postGIS in the production environment

The production environment is as follows:

Operating System:

CentOS release 5.5 (Final)

Installation required:

Postgresql address: http://www.postgresql.org/ftp/source/

PostgisAddress: http://postgis.refractions.net/download/

Proj address: http://trac.osgeo.org/proj/

Geos address: http://trac.osgeo.org/geos/

Installation steps:

The postgre installation version is 9.1.3.

  • Wget http://ftp.postgresql.org/pub/source/v9.1.3/postgresql-9.1.3.tar.bz2
  • Tar-jxvf postgresql-9.1.3.tar.bz2
  • Cd postgresql-9.1.3
  • ./Configure
  • Gmake --> All of PostgreSQL successfully made. Ready to install.
  • Gmake install --> PostgreSQL installation complete.

Vim INSTALL:

  • ./Configure
  • Gmake
  • Su
  • Gmake installInstall the software to the specified prefix directory in the specified configuration phase
  • Adduser postgresAdd the ipvs user, default Super administrator of postgreSQL
  • Mkdir/usr/local/pgsql/dataCreate a directory for storing data
  • Chown postgres/usr/local/pgsql/dataChange file owner
  • Su-postgresSwitch to postgres user
  • /Usr/local/pgsql/bin/initdb-D/usr/local/pgsql/dataInitialize the storage range of the database on the disk
  • --A notification will be sent when the call is successful./Usr/local/pgsql/bin/postgres-D/data/pgsql or/usr/local/pgsql/bin/pg_ctl-D/data/pgsql-l logfile start
  • /Usr/local/pgsql/bin/postgres-D/usr/local/pgsql/data> logfile 2> & 1 &Specify the data directory to start the database server (the output is redirected to logfile and runs in the background. You can also use pg_ctl to start it)
  • /Usr/local/pgsql/bin/createdb testCreate a test database and confirm the installation is successful.

...

Configure the environment variables:

LD_LIBRARY_PATH =/usr/local/pgsql/libDirectory of the dynamic Connection Library

PATH =/usr/local/pgsql/bin: $ PATHFor ease of use, add the search path of the command

Enter pg_config to view

  • BINDIR =/usr/local/pgsql/bin
  • DOCDIR =/usr/local/pgsql/share/doc
  • HTMLDIR =/usr/local/pgsql/share/doc
  • INCLUDEDIR =/usr/local/pgsql/include
  • PKGINCLUDEDIR =/usr/local/pgsql/include
  • INCLUDEDIR-SERVER =/usr/local/pgsql/include/server
  • LIBDIR =/usr/local/pgsql/lib
  • PKGLIBDIR =/usr/local/pgsql/lib
  • LOCALEDIR =/usr/local/pgsql/share/locale
  • MANDIR =/usr/local/pgsql/share/man
  • Export dir =/usr/local/pgsql/share
  • SYSCONFDIR =/usr/local/pgsql/etc
  • PGXS =/usr/local/pgsql/lib/pgxs/src/makefiles/pgxs. mk
  • CONFIGURE =
  • CC = gcc
  • CPPFLAGS =-D_GNU_SOURCE
  • CFLAGS =-O2-Wall-Wmissing-prototypes-Wpointer-arith-Wdeclaration-after-statement-Wendif-labels-Wformat-security-fno-strict-aliasing-fwrapv
  • CFLAGS_SL =-fpic
  • LDFLAGS =-Wl,-rpath, '/usr/local/pgsql/lib', -- enable-new-dtags
  • LDFLAGS_EX =
  • LDFLAGS_SL =
  • LIBS =-lpgport-lz-lreadline-ltermcap-lcrypt-ldl-lm
  • VERSION = PostgreSQL 9.1.3

PostgreSQL installation is complete.

Note: When installing ipvs

Readline Library (default): the command line editing function. This library is not required (you can cancel it by using the -- without-readline option in the configuration phase), but we strongly recommend that you install readline,

When psql is used, you can use the direction keys to select and edit the commands you typed earlier.

Check whether the installation is successfulRpm-qa | grep readline

The zlib library (default) is mainly used for data compression for pg_dump and pg_restore operations. This library is not required (you can cancel it by using the -- without-zlib option in the configuration phase ),

Check whether rpm-qa | grep zlib has been installed.

You must install these packages before compiling the program. Otherwise, you cannot compile the program. In addition, there are many optional packages in the configuration phase, which can be viewed through./configure -- help.

Option description

-Prefix =PrefixInstall it to the directory pointed to by prefix. The default value is/usr/local/pgsql.

-Bindir =DirInstall the application to dir. The default value is prefix/bin.

-With-d ocdir =DirInstall the document to dir. The default value is prefix/doc.

-With-p gport =PortSet the default TCP port number for the server network Connection Service

-With-t cl provides Tcl Stored Procedure Support for the server.

-With-p erl provides Perl Stored Procedure Support for the server.

-With-p ython provides Python Stored Procedure Support for the server.

The PostGIS installation version is PostGIS 1.5.4 Release.

First download source package proj-4.8.0, geos-3.3.3, libxml2-2.6.26, although these three libraries are not mandatory to install postgis, but, without these three packages,

To some extent, postgis has lost the significance of spatial databases. Because Proj4 provides projection-related operations, such as the transform () function in postgis, geos provides many topologies for postgis.

  • 1
  • 2
  • Next Page

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.