.

PHP Everywhere Home

Home    Feedback   Join Now   Login  

Tips on Installing PostgreSQL on Windows

Mail This Story   Thu, Nov 7, 2002; by John Lim.

First get the CygWin install, which emulates a Unix command shell, from http://cygwin.com/

Make sure that in setup.exe you select databases and include postgresql and less (needed by psql). Also download vim as the default vi editor is the crappy stevie.

Then download ipcdeamon install from http://www.neuro.gatech.edu/users/cwilson/cygutils/cygipc/index.html

Then

chmod a+x /usr/bin

because the permissions are incorrect!

Then read the following:

http://www.ejip.net/faq/postgresql_win_setup_faq.jsp

or the install instructions included in cygwin shell (which are not so accurate)...

/usr/doc/Cygwin:

Additional Notes

Don't forget to run postmaster with the -i option if you have an Connection Refused message, to allow to TCP/IP access.

Also download phpPgAdmin to administer your databases from a web server.

To determine which file maps to which database or table, use

  select datname,oid from pg_database
  select relname, relfilenode from pg_class

Funnily, plpgsql is not installed by default. Make sure you add it to your databases, eg for template1, from the cygwin cmd-line:

createlang plpgsql template1

Tuning

Bruce Momjian: http://www.ca.postgresql.org/docs/momjian/hw_performance/

Misc Tuning Tips: http://techdocs.postgresql.org/techdocs/pgsqldbtuning.php


$Id: README,v 1.22 2002/06/10 11:33:58 jt Exp $

Abstract:

This is the README for the Cygwin PostgreSQL distribution.

PostgreSQL is an advanced Object-Relational database management system (DBMS) that supports almost all SQL constructs (including transactions, subselects and user-defined types and functions).

The Cygwin PostgreSQL package is very monolithic compared its RPM counterparts and its contents is roughly analogous to the aggregation of the following PostgreSQL RPMs:

postgresql-devel postgresql-docs postgresql-jdbc postgresql-libs postgresql-perl postgresql-python postgresql-server

Requirements:

The following packages or later are required to build and/or execute Cygwin PostgreSQL:

crypt 1.0-1 cygipc 1.11-1 readline 4.2a-1 libreadline5 4.2a-1 zlib 1.1.3-6 cygwin 1.3.10-1

Sun JDK 1.3 Ant 1.3

Install:

There are two types of Cygwin PostgreSQL installations -- basic and NT services. The basic installation is good for casual use on any version of Windows, but required on Windows 9x/Me. The NT services installation is good for a more production environment, but is only available on Windows NT/2000. Note that this installation type is very similar to the normal Unix installation with just some Cygwin/Windows variations. You should choose the type which best meets your needs and/or is constrained by your platform.

Regardless of the installation type, the first step is to install the latest cygipc from:

http://www.neuro.gatech.edu/users/cwilson/cygutils/cygipc/index.html

The following is the basic Cygwin PostgreSQL installation procedure:

1. Start the cygipc ipc-daemon:

$ ipc-daemon &

2. Initialize PostgreSQL:

$ initdb -D /usr/share/postgresql/data

3. Start the PostgreSQL postmaster:

$ postmaster -D /usr/share/postgresql/data &

4. Connect to PostgreSQL:

$ psql template1

The following is the NT services Cygwin PostgreSQL installation procedure:

1. Install the cygipc ipc-daemon as a NT service:

# ipc-daemon --install-as-service

2. Create the "postgres" user account:

# cmd /c lusrmgr.msc # [3] # mkpasswd -l -u postgres >>/etc/passwd

3. Grant the "postgres" user the "Log on as a service" user right:

# cmd /c secpol.msc [4]

4. Install postmaster as a NT service (one line):

# cygrunsrv --install postmaster --path /usr/bin/postmaster --args "-D /usr/share/postgresql/data -i" --dep ipc-daemon --termsig INT --user postgres --shutdown # [5] [6]

5. Create the PostgreSQL data directory:

# mkdir /usr/share/postgresql/data

6. Change ownership of the PostgreSQL data directory:

# chown postgres /usr/share/postgresql/data

7. Initialize PostgreSQL (*when running under the "postgres" account*):

$ initdb -D /usr/share/postgresql/data

5. Start the cygipc ipc-daemon:

# net start ipc-daemon # [7]

6. Start postmaster:

# net start postmaster # [7]

7. Connect to PostgreSQL:

# psql -U postgres template1 [8] [9]

The following are the notes to the above:

[1] The "#" prompt indicates running as a user which is a member of the Local Administrators group. [2] The "$" prompt indicates running as the "postgres" user. Log in as "postgres" or use ssh to emulate Unix's "su" command. [3] On Windows 2000, this starts the "Local Users and Groups" applet. On Windows NT 4.0, do the analogous operation. [4] On Windows 2000, this starts the "Local Security Settings" applet. On Windows NT 4.0, do the analogous operation. [5] Do not use rxvt for this step because the password exchange will not work properly. [6] Clean postmaster shutdown will only work with a post Cygwin 1.3.2 snapshot from 2001-Jul-28 or later. [7] Cygwin's bin directory (e.g., C:Cygwinbin) must be added to the Windows NT/2000's system PATH and the machine rebooted for the SCM to find cygwin1.dll. [8] Actually, psql can run under any user account. [9] One can use PostgreSQL's createuser command or set PGUSER to obviate the need to specify "-U postgres" on the psql command line.

Source:

As configured, the PostgreSQL source builds OOTB under Cygwin with only one minor Perl related caveat. So, the source has been patched to correct this issue. I have submitted the following patch:

http://archives.postgresql.org/pgsql-patches/2002-02/msg00029.php

for consideration and it has been accepted into PostgreSQL CVS.

Additionally, the source has been patched so that InstallXLogFileSegment() uses rename() instead of link()/unlink() to avoid a Windows open file permission denied problem. I have submitted the following patch:

http://archives.postgresql.org/pgsql-patches/2002-05/msg00029.php

for consideration and it has been accepted into PostgreSQL CVS.

I also added the following files to the source archive:

CYGWIN-PATCHES/README CYGWIN-PATCHES/build.sh CYGWIN-PATCHES/postgresql.patch

and renamed the original source archive to match Cygwin's setup.exe naming conventions.

To restore the PostgreSQL source to its original state, perform the following:

$ cd postgresql-$version-$package $ patch -R -p1 <CYGWIN-PATCHES/postgresql.patch $ rm -fr CYGWIN-PATCHES

where $version is the PostgreSQL version (e.g., 7.2) and $package is the Cygwin package number.

Build:

This distribution has been configured as follows (one line):

configure --enable-multibyte --with-python --with-perl --with-java --with-CXX --prefix=/usr --sysconfdir=/etc --docdir=/usr/doc/postgresql-$version

where $version is the PostgreSQL version (e.g., 7.2).

See CYGWIN-PATCHES/build.sh in the source archive for my exact build recipe for configuring, making, and packaging this distribution.

Test:

On 9X/ME, it has been reported that Cygwin PostgreSQL hangs at random places during the regression test. Unfortunately, at the time of this writing, no one has tracked down the root cause of these hangs.

Issues:

1. make check can generate spurious regression test failures due to overflowing the the listen() backlog queue which generates connection refused errors. Note that make installcheck does not have this problem since it runs all tests sequentially instead of in large concurrent groups.

2. It is recommended to delete all cygipc temporary files (/tmp/cygipc* and /tmp/MultiFile*) before starting postmaster under a different user account. Otherwise, postmaster will fail to start due to IPC errors.

Homepage:

The primary PostgreSQL web site is:

http://www.postgresql.org/

Download:

The primary PostgreSQL ftp site is:

ftp://ftp.postgresql.org/

Mailing Lists:

Please report problems, suggestions, etc. dependent on their nature to one of the following:

pgsql-cygwin@postgresql.org cygwin@cygwin.com

Maintainer:

Jason Tishler <jason@tishler.net>

Read/Post Responses (Join/Login first)

Mail This Story

 
Get your site hosted using Manila!
Free Software
A high quality database library:
ADOdb 3.72   download
New: sqlite and sapdb drivers.
ADOdb Help & Dev Forum

ADOdb Documentation:
  - English
  - Francais
Tutorial:
  - English
  - German
  - Spanish
  - Thai
  - Polish
FAQ

ADOdb Articles:
  - PHP4 Sessions with ADOdb
  - Cool ADOdb applications
  - ADOdb testimonials
  - Comparing PEAR DB and ADOdb
  - Writing Portable SQL
  - Web Services with ADOdb
  - ADOdb date library

-Commercial data component: phpLens

Our RSS Newsfeed
PHP Advocacy
Interviews
Michael Kimsal
Zeev Suraski

-Comparing PHP with .NET
-PHP versus ASP
-Why PHP is better than ASP
-PHP versus Cold Fusion
-PHP versus Perl
-What's wrong with JSP?
-PHP,ASP,JSP,CFM Popularity

Enterprise PHP
-Enterprise PHP scalable, high availability
-Writing Reliable Software
-PHP Application Variables
-Sessions in a Server Farm with ADOdb
-PHP, FastCGI and IIS

-Optimizing PHP: tips, methodologies and examples.
-Tuning PHP and Apache: many tips and links.

PHP Articles
-PEAR Tutorials & Links
-PHP Windows/Unix Editors
-PHP Caches & Debuggers

-XML-RPC Web Services
-ActiveX on Linux
-PHP: COM & ADO
-GD on Windows
-Using mail()

Some notes comparing PHP, JScript, VBScript and ASP that might be useful
1. Language Basics
2. Functions, Classes
3. ASP Objects and PHP

-My Favorite Articles
-CVS on Windows

PHP and SQL Databases
-SQL Tutorials & Resources
-Transactions in MySQL
-PHP ODBC Tips
-Flying with MySQL & Oracle
-Object-Relational Mania
-MySQL vs MSSQL vs Access
- also see ADODB above.

Apache and IIS
-Unix Performance Analysis
-Securing Apache on Linux
-Porting Apache to IIS
-PHP CGI in IIS
-Windows Apache & PHP

Tips
-Var_Dump & Print_R
-Prevent Caching
-E-mail Your Errors
-Disable magic_quotes_gpc
-Stop Submitting Twice
-Document Code Quickly
-Fault Tolerant Connections
-HTTP Compression
-XML DOM for Windows

Links
PHP.Net Home Manual Bugs
Writing a PHP Extension
Zend.com: PHP Portal
PHPBuilder.com: Articles
HotScripts Code Snippets
PHP Resource Index
PHP Source Code ChangeLog

Evil Walrus
phpinfo.net: French e
phpitalia.com: Italian e
phparchiv.de: German
php-resource: German e
PHP-Center.de: German e
phpuser.com: Chinese
hot PHP Web Cards
Cool Javascripts
More Links

Learn PHP
Forums Ask for HELP here!
or try the KnowledgeBase

Good Intro to PHP
PHP Overview by Rasmus
Intro to PHP


Regular Expressions Intro   txt2regex
Advanced Reg. Expressions
Database Readings PalsLib

Downloads
Bad Blue: Web Server
phpBB: Excellent Forum
ASP2PHP: Converts VB to PHP.
Web Calendar Nice

Archives
-My Favorite Articles
-2003
-2002
-2001
-2000

PHP4.0.4 Installer
php_gd.dll with GIF


Put the following ADODB logo on your website if you like!

John Lim Malaysia Natsoft Juris Legalpro iJuris mydevotion Tips.

All original materials (c) 2000-2003 John Lim