Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

PostgreSQL and PHP install tutorial UNIX
If you'd like to get PostgreSQL and PHP running on Mac OS X, the following tutorial should help. Please refer to my previous instructions on installing Apache, PHP, MySQL in this web site to make these instruction clearer.

- Vip Malixi.

[Read the rest of the article for the step-by-step instructions]

NOTE: Do not type the "%" sign; it's the indicator for the command prompt, not part of each command...
  1. First download the postgres tar ball from the web site. I was successful with this version: postgresql-7.1.2.tar.gz

  2. Copy it to your main user's Documents folder

  3. Open Terminal and go to the Home Documents directory:
    cd ~/Documents

  4. Become Root (su), then untar and unzip:
    % gzip -dc postgresql-7.1.2.tar.gz | tar xvf -

  5. Go to the newly created directory:
    cd postgresql-7.1.2

  6. Configure, make and install:
    % ./configure
    % make
    % make install

  7. exit as Root:
    % exit

  8. Open up System Preferences | Users

  9. Create a new user called "postgres" with password "postgres" with no admin privileges

  10. Go back to terminal application and as Root change ownership of /usr/local/pgsql to user postgres:
    % chown postgres /usr/local/pgsql

  11. Become user postgres:
    % su postgres

  12. Initialize postgres databases:
    % /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data

  13. Test by running the postgres server:
    % /usr/local/pgsql/bin/postmaster -i -S -D /usr/local/pgsql/data &

  14. Create a test database:
    % /usr/local/pgsql/bin/createdb test

  15. Test running postgres:
    % /usr/local/pgsql/bin/psql test

  16. Try running a SQL command while inside postgres, then when it works, quit:
    > select datetime 'now';
    > q

  17. Still as user postgres, create a postgres user for yourself:
    First find out your user name:
    % whoami

    [Editor's question: If you're still user 'postgres', won't this return 'postgres'?]

    --let's say your user name is "dalailama":
    % /usr/local/pgsql/bin/createuser dalailama

  18. You're all set. If you want, you can delete the postgres install directory so as not to waste space. First go to Terminal and as Root change ownership of that directory to yourself:
    % chown dalailama postgresql-7.1.2
    % exit

  19. You can now trash that directory from Home | Documents

  20. If you want to be able to access postgres from PHP, referring to my previous instructions on how to install Apache, MySQL, PHP, just modify the PHP configure (also, the latest PHP version works pretty well, no more need to disable pear (php-4.0.6.tar.gz) which you can get from
    % ./configure --with-mysql --with-pgsql --with-dbase --with-apsx --enable-track-vars

  21. I got an error during the make of PHP on MacOSX (w/c I didn't get when I installed in Linux) with the postgres option which I was able fix (through pure guesswork and trial and error). This is how I fixed the make error: as Root, do the following if you get a "run ranlib" error during php make:
    % cd /usr/local/pgsql/lib
    % ranlib -sct libpq.a

  22. After doing this, I was able to complete the php make and make install. Go back to where we were configuring PHP and do the following:
    % make
    % make install

  23. There. Now run the postgres server, mysql server, and apache server to test everything. Good luck.
[Editor's note: I have not tried this myself yet...mySQL is still keeping me plenty busy! ;-) ]
  • Currently 3.67 / 5
  You rated: 2 / 5 (3 votes cast)

PostgreSQL and PHP install tutorial | 1 comments | Create New Account
Click here to return to the 'PostgreSQL and PHP install tutorial' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
PostgreSQL and PHP install tutorial
Authored by: mkwan017 on Jun 09, '04 03:00:55AM

I get compile errors when I try to do a 'make' after ./configure with pgsql option.

make: *** [libs/libphp4.bundle] Error 1

what does that mean and how do I fix it?



[ Reply to This | # ]