.. _geoserver.postgis.postgres_install:

Installing PostgreSQL
---------------------

This section covers the installation of PostgreSQL, the database engine that 
PostGIS runs on. Version 8.2 of PostgreSQL will be installed via the PostgreSQL Windows installer.

#. Navigate to the workshop :file:`software` directory.

#. Run the PostgreSQL installer by double-clicking on the file named :file:`postgresql-8.2.msi`, or alternatively by *right-clicking* on the file and selecting :guilabel:`Install`.

   .. figure:: postgres_install01.jpg

      Running the PostgreSQL installer

#. Begin the installer by selecting the language of your choice and clicking **Start**.

   .. figure:: postgres_install02.jpg

      Choosing a language for installation

#. On the Welcome screen click **Next**.

#. Accept the :guilabel:`License Agreement / Installation Notes` and click :guilabel:`Next`.

   .. figure:: postgres_install03.jpg

      Reviewing the PostgreSQL license agreement

#. On the **Installation Options** screen, accept all the defaults and click :guilabel:`Next`.

   .. figure:: postgres_install04.jpg
 
      Specifying PostgreSQL installation options

   .. note:: The PostGIS extensions should be left **disabled**.  They will be installed in the next section.

#. On the **Service Configuration** screen, enter the password "postgres2008" and click **Next**. When asked to create a new account, click **Yes**.

   .. figure:: postgres_install05.jpg

      Specifying the postgres account information 

   .. note:: For security reasons PostgreSQL requires a non-privileged account to be installed. The installer will create one for you. This account can be removed later.

   .. figure:: postgres_install06.jpg

      Creating the postgres account

   .. note:: Any warning about weak passwords can be ignored.

#. On the **Initialize Database Cluster** screen, enter the password "postgres" (note that this is different from the password in the previous step), and click **Next**.
 
   .. figure:: postgres_install07.jpg

      Initializing PostgreSQL

   .. note:: The database super user is **different** from the Windows user account created in the previous step.

#. Continue through the rest of the installer accepting the defaults.

   .. figure:: postgres_install08.jpg

      Enabling the PL/pgsql procedural language

   .. figure:: postgres_install09.jpg

      Enabling contrib modules

   .. figure:: postgres_install10.jpg

      Starting the installation phase

#. Finalize the installation and exit the installer.

   .. figure:: postgres_install11.jpg

      Installation progres

   .. figure:: postgres_install12.jpg

      Finishing the PostgreSQL installation

At this point the PostgreSQL database is installed and should be running on the system. The installation can be verified by starting windows command prompt and executing the command::

	  C:\Program Files\PostgreSQL\8.2\bin\psql -U postgres -l

If a list of databases is returned then the installation was carried out successfully. In the :ref:`next <geoserver.postgis.postgis_install>` section the PostGIS spatial extensions or PostgreSQL will be installed.

