====== Installing PostgreSQL on Windows ====== In this tutorial I set up PostgreSQL as server for BPS on a windows 7 workstation, for example as a testing environment. Newer releases of PostgreSQL might have slightly different procedures, but the overall process should be more or less the same. Other flavors of windows will basicly also work the same way. This tutorial is addressing people who are not yet familiar with PostgreSQL administration and want to install it first time. If you need to install the database in a more complex environment, on an other operating system, or need to tune the database for maximum performance, please check out the PostgreSQL documentation instead. ===== Downloading the Software ===== The website of the PostgreSQL project my change over time, so take the following instructions just as general direction how to find and download the correct package. You should find the site at [[http://www.postgresql.org/]]. Find the download page and go for the latest release: {{ bps2:pgsqlwinsrv:img-1000.png?600 |Download of the software}} Choose the binary windows 32 bit distribution. {{ bps2:pgsqlwinsrv:img-1001.png?600 |Select 32-bit Windows}} Choose the one-click installer: {{ bps2:pgsqlwinsrv:img-1002.png?600 |The one-click installer}} Take the latest available release: {{ bps2:pgsqlwinsrv:img-1003.png?600 |Latest release}} {{ bps2:pgsqlwinsrv:img-1004.png |Downloading}} ===== Installing the Software ===== Start the downloaded installer: {{ bps2:pgsqlwinsrv:img-1005.png |Installer}} Click //Next// after enjoying the welcome screen: {{ bps2:pgsqlwinsrv:img-1006.png |Welcome}} I recommend to use the suggested installation directory if you have no special reason to use another path: {{ bps2:pgsqlwinsrv:img-1007.png |Installation directory}} The data directory is suggested to go also in the program folder. I think that is not the most smart option, from a perspective of separating application and data, as well as backup, it might be better to select another directory: {{ bps2:pgsqlwinsrv:img-1008.png |Data directory}} Choose a password for the the //postgres// accounts in the database (as superuser account) and in windows (as account where the service will run under): {{ bps2:pgsqlwinsrv:img-1009.png |Superuser and service account}} If the default port 5432 is not yet taken by another TCP/IP service on the machine, I recommend to leave the default: {{ bps2:pgsqlwinsrv:img-1010.png |Port}} Leave the advanced options as suggested: {{ bps2:pgsqlwinsrv:img-1011.png |Advanced options}} Click //Next// on the ready to install screen: {{ bps2:pgsqlwinsrv:img-1012.png |Ready to install}} Wait until the software is installed: {{ bps2:pgsqlwinsrv:img-1013.png |Installation progress}} On the final screen, uncheck the stack builder launch option and click //Finish//. {{ bps2:pgsqlwinsrv:img-1014.png |Installer}} The software is now installed on your computer. ===== Setting the Environment Variables ===== After installation the system PATH environment variable needs to be extended by the PostgreSQL directories holding EXE's and DLL's so applications like BPS can find the drivers automatically. The procedure for Windows 7 is described below. Open the //Start// menu, right click on //Computer// and click on //Properties//: {{ bps2:pgsqlwinsrv:img-1020.png |Computer Properties}} Click on //Advanced system settings//: {{ bps2:pgsqlwinsrv:img-1021.png |Advanced system settings}} In the //Advanced// tab, click on //Environment Variables...//: {{ bps2:pgsqlwinsrv:img-1022.png |Environment Variables}} Edit //Path// unter //System variables//: {{ bps2:pgsqlwinsrv:img-1023.png |System variables}} Add the //bin// and //lib// paths of your PostgreSQL installation folder to the end of the list, separating the paths by semicolon: {{ bps2:pgsqlwinsrv:img-1024.png |Path}} Save the settings: {{ bps2:pgsqlwinsrv:img-1025.png |Save}} Under Windows 7 the changes to the system path are immediately valid for subsequent started programs. If you are however installing on another Windows version, it might be necessary to reboot the computer. ===== Making server available for clients ===== The default does not allow accessing the datastore from other client machines. If you only want a single testing machine this is ok and you can skip this chapter. However for a real installation you need to do the following additional steps on the server PC: - Make the service accept external connections - Configure windows firewall to allow external access to the TCP/IP port To configure the service, start up PgAdmin III and connect as //postgres//: {{ :bps2:pgsqlwinsrv:img-0000.png?650 |PgAdmin III}} Select the default postgres database, open the tools menu, server configuration, pg_hba.conf: {{ :bps2:pgsqlwinsrv:img-0001.png?650 |pg_hba.conf}} Select the yet empty record and double click on it to open it for editing: {{ :bps2:pgsqlwinsrv:img-0002.png |List}} Enter the settings as below, but at the IP address enter the network address of your own LAN in CIDR notation instead. (My LAN in the example below has the IP addresses 10.56.xxx.xxx, with the first 16 bits relevant for network identification, hence the /16): {{ :bps2:pgsqlwinsrv:img-0003.png |Edit Record}} After confirming the dialog with OK, click on the save and then on the reload button to make the service start with the new settings. You will see two reminder windows about being sure that the settings are ok, which you can confirm (if everything entered ok): {{ :bps2:pgsqlwinsrv:img-0004.png |Save and Reload}} Next you must add a rule to the firewall to allow external (incoming) access on TCP/IP port 5432: {{ :bps2:pgsqlwinsrv:img-0005.png |Add firewall rule}} {{ :bps2:pgsqlwinsrv:img-0006.png?650 |Add firewall rule}} {{ :bps2:pgsqlwinsrv:img-0007.png?600 |Add firewall rule}} {{ :bps2:pgsqlwinsrv:img-0008.png?600 |Add firewall rule}} {{ :bps2:pgsqlwinsrv:img-0009.png?600 |Add firewall rule}} {{ :bps2:pgsqlwinsrv:img-0010.png?600 |Add firewall rule}} {{ :bps2:pgsqlwinsrv:img-0011.png?600 |Add firewall rule}} {{ :bps2:pgsqlwinsrv:img-0012.png?650 |Add firewall rule}} ===== What next ===== You may continue now with: [[pg-preparation|Preparing PostgreSQL for BPS]]