Professional Documents
Culture Documents
peter@peter-siegel.de
The question which database server should be applied is discussed widely and
even controversially all around the internet. MySQL and PostgreSQL have
different advantages, it seems that they appear to converge to meet somewhere
in the middle. For some time PostgreSQL provides foreign keys, views,
subselects, triggers and stored procedures. MySQL is topping with performance
and a large user base. In actual versions MySQL is adding features like stored
procedures, subselects, etc. while PostgreSQL improves performance and
stability. Nevertheless which database server fits best depends on the
applications that should work with it.
This paper is designed as a short manual that shows how XAMPP could be
extended easily by PostgreSQL and phpPgAdmin. Is has been written during the
setup of my private experimental Web/DBServer. So all described steps have led
to a smooth integration of PostgreSQL into a running system based on XAMPP
and Debian Sarge. This paper is dedicated to anybody who doesn't want to spend
much time searching the web for hints and tips. However, this howto-manual
doesn't raise a claim on completeness. No liability for any loss or damage will be
assumed.
Extending XAMPP with PostgreSQL and phpPgAdmin 2/19
pre-requisites
software components
System Linux, Distribution SuSE 9.1 Personal
PostgreSQL Version 8.1.1
RPM Packages:
postgresql-8.1.1-0.1.i586.rpm
postgresql-contrib-8.1.1-0.1.i586.rpm
postgresql-devel-8.1.1-0.1.i586.rpm
postgresql-docs-8.1.1-0.1.i586.rpm
postgresql-libs-8.1.1-0.1.i586.rpm
{postgresql-pl-8.1.1-0.1.i586.rpm}
postgresql-server-8.1.1-0.1.i586.rpm
available at:
ftp://ftp.suse.com/pub/projects/postgresql/postgresql-8.1.1/9.1-i386/
PostgreSQL XAMPP 1.5.0 provides a PostgreSQL driver for PHP5 by default. Normally, no
database additional driver libraries need to be installed. Otherwise, this SuSE 9.3 package has
modules for to be installed:
PHP 5
Version 5.0.3-14
Packages:
php5-pgsql-5.0.3-14.i586.rpm
Package:
xampp-linux-1.5.0.tar.gz
phpPgAdmin Version 4.0.1
available at http://phppgadmin.sourceforge.net/
Package:
phpPgAdmin--4.0.1.tar.gz
Extending XAMPP with PostgreSQL and phpPgAdmin 3/19
Installing XAMPP
Unpack the XAMPP package into the directory '/opt'. An automatically created
subdirectory '/opt/lampp' is filled with the package content. Apply the following
console entry:
The following startup script should be saved into directory '/etc/init.d'. At system
startup, different services are going to be executed by start scripts. These scripts
are originally located in directory '/etc/init.d' and they are registered by a soft
link in at least one run level directory from 'rc0.d' to 'rc6.d'. All soft linked start
scripts in one associated run level directory are called by the entry the run level
master script '/etc/init.d/rc'.
Extending XAMPP with PostgreSQL and phpPgAdmin 4/19
XAMPP_DIR=/opt/lampp
case "$1" in
start)
stop)
restart)
## Stop the service and regardless of whether it was
## running or not, start it again.
$0 stop
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac
exit 0
Extending XAMPP with PostgreSQL and phpPgAdmin 5/19
The start script can be executed automatically on system bootup. This can be set
up with the runlevel editor in YaST:
Extending XAMPP with PostgreSQL and phpPgAdmin 6/19
# /opt/lampp/lampp start
# /opt/lampp/lampp security
Launching the XAMPP page in a web browser under Echnaton's IP address will
show a login window like this:
Extending XAMPP with PostgreSQL and phpPgAdmin 7/19
Launching the phpMyAdmin page in a web browser under the server address
"http://192.168.10.3/phpmyadmin" will show a login window like this:
Extending XAMPP with PostgreSQL and phpPgAdmin 8/19
Installing PostgreSQL
# rpm -i postgresql-8.1.1-0.1.i586.rpm
# rpm -i postgresql-contrib-8.1.1-0.1.i586.rpm
# rpm -i postgresql-devel-8.1.1-0.1.i586.rpm
# rpm -i postgresql-docs-8.1.1-0.1.i586.rpm
# rpm -i postgresql-libs-8.1.1-0.1.i586.rpm
# rpm -i postgresql-server-8.1.1-0.1.i586.rpm
Typically, the superuser is equal to a linux user named "postgres" who belongs to
group "postgres". Following steps show the linux console entries for creating or
even changing the specified group and user:
4. Adjust rights for user 'postgres' allowing access to the home directory
# chown postgres:postgres /home/postgres/
# chmod 700 /home/postgres/
Switch to user “postgres” with all rights and initialize the database cluster by
following command lines:
# su – postgres
# mkdir /home/postgres/data
# initdb -D /home/postgres/data
With option ”-D“ you can offer a directory that stores the database files and the
data content files, respectively. Following output is printed to console:
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
The database cluster will be initialized with locale C.
fixing permissions on existing directory /home/postgres/data ... ok
creating directory /home/postgres/data/global ... ok
creating directory /home/postgres/data/pg_xlog ... ok
creating directory /home/postgres/data/pg_xlog/archive_status ... ok
creating directory /home/postgres/data/pg_clog ... ok
creating directory /home/postgres/data/pg_subtrans ... ok
creating directory /home/postgres/data/pg_twophase ... ok
creating directory /home/postgres/data/pg_multixact/members ... ok
creating directory /home/postgres/data/pg_multixact/offsets ... ok
creating directory /home/postgres/data/base ... ok
creating directory /home/postgres/data/base/1 ... ok
creating directory /home/postgres/data/pg_tblspc ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 1000
creating configuration files ... ok
creating template1 database in /home/postgres/data/base/1 ... ok
initializing pg_authid ... ok
enabling unlimited row size for system tables ... ok
initializing dependencies ... ok
creating system views ... ok
loading pg_description ... ok
creating conversions ... ok
setting privileges on builtin objects ... ok
creating information schema ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok
Extending XAMPP with PostgreSQL and phpPgAdmin 10/19
WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the A option the
next time you run initdb.
Success. You can now start the database server using:
postmaster D /home/postgres/data
or
pg_ctl D /home/postgres/data l logfile start
Solution: Download and install the basic system library for accessing the
termcap database
(ftp://search.belnet.be/packages/suse/suse/i386/9.3/suse/i586/termcap-2.0.8-876.i586.rpm)
# rpm -i libtermcap-2.0.8-876.i586.rpm
Extending XAMPP with PostgreSQL and phpPgAdmin 11/19
export PGBIN=/usr/bin/
export PGDATA=/home/postgres/data
case "$1" in
start) echo Starting PostgreSQL
su postgres -c '$PGBIN/pg_ctl -s -D $PGDATA -l /home/postgres/logfile start'
;;
stop) echo Shutting down PostgreSQL
su postgres -c '$PGBIN/pg_ctl stop'
;;
restart)
$0 stop
$0 start
;;
reload)
su postgres -c '$PGBIN/pg_ctl -s -D $PGDATA -l /home/postgres/logfile reload'
;;
exit 0
Check the file “/etc/services” these entries that open port 5432 for accessing the
PostgreSQL database server:
Extending XAMPP with PostgreSQL and phpPgAdmin 12/19
There are different ways a PostgreSQL database server can be accessed. Two
possible configurations are described in the following track:
#---------------------------------------------------------------------------
# CONNECTIONS AND AUTHENTICATION
#---------------------------------------------------------------------------
# - Connection Settings -
listen_addresses = '192.168.10.3'
# what IP interface(s) to listen on;
# defaults to localhost, '*' = any
port = 5432
The connection settings above belong to the server on which the Postgres
database is running. For example, the database server should be accessed by
connections on a built in network interface card that is configured with IP
address 192.168.10.3. All database connections are passing port 5432.
Change the valid address for Ipv4 connections to the client's IP that is granted
to access the database.
Extending XAMPP with PostgreSQL and phpPgAdmin 13/19
Some entries in the PostgreSQL configuration files are needed for granting
access to a PostgreSQL database server:
Change the valid address for Ipv4 connections to the localhost IP 127.0.0.1.
#---------------------------------------------------------------------------
# CONNECTIONS AND AUTHENTICATION
#---------------------------------------------------------------------------
# - Connection Settings -
listen_addresses = 'localhost'
# what IP interface(s) to listen on;
# defaults to localhost, '*' = any
port = 5432
2nd: Create a link to the shared object library that belongs to the PostgreSQL
driver for PHP5. In XAMPP 1.5.0 a PostgreSQL driver for PHP 5 is provided
in directory for PHP extensions “/opt/lampp/lib/php/extensions/no-debug-
non-zts-20041030”. A link to the Postgres-PHP driver is expected in the
system directory “/usr/lib/php5/extensions”. Apply the following console
entry for creating an appropriate link:
# ln -s /opt/lampp/lib/php/extensions/no-debug-non-zts-20041030/pgsql.so
/usr/lib/php5/extensions/pgsql.so
4th: Edit the configuration file for your PostgreSQL database cluster at
“/home/postgres/data/postgresql.conf”. Set the properties for database
access through a network. Make sure that the connection settings
correspond with these values:
You should pay attention to the settings for local connections from localhost.
Set the authentication method to “md5”, otherwise phpPgAdmin doesn't
verify any password for logins of superuser “postgres”. That means anybody
can login as superuser without giving any password.
/**
* Central phpPgAdmin configuration. As a user you may modify the
* settings here for your particular configuration.
*
* $Id: config.inc.php-dist,v 1.35.2.2 2005/02/11 11:23:39 chriskl Exp $
*/
// Hostname or IP address for server. Use '' for UNIX domain socket.
$conf['servers'][0]['host'] = '127.0.0.1'; // pjs
// Specify the path to the database dump utilities for this server.
// You can set these to '' if no dumper is available.
$conf['servers'][0]['pg_dump_path'] = '/usr/bin/pg_dump';
$conf['servers'][0]['pg_dumpall_path'] = '/usr/bin/pg_dumpall';
// Send XHTML headers? Unless debugging, it's best to leave this off
$conf['use_xhtml'] = false;
/*****************************************
* Don't modify anything below this line *
*****************************************/
$conf['version'] = 13;
?>
Extending XAMPP with PostgreSQL and phpPgAdmin 17/19
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output
started at /opt/lampp/phpPgAdmin/libraries/lib.inc.php:77) in /opt/lampp/phpPgAdmin/libraries/lib.inc.php on
line 77
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent
(output started at /opt/lampp/phpPgAdmin/libraries/lib.inc.php:77) in /
opt/lampp/phpPgAdmin/libraries/lib.inc.php on line 77
and add a directory with public access like it's shown here:
The directory “/tmp” is the default location for saving sessions in PHP. It's
appropriate entry can be found in configuration file “/opt/lampp/etc/php.ini”,
parameter “session.save_path”.
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output
started at /opt/lampp/phpPgAdmin/logout.php:11) in /opt/lampp/phpPgAdmin/logout.php on line 11
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent
(output started at /opt/lampp/phpPgAdmin/logout.php:11) in /opt/lampp/phpPgAdmin/logout.php on line 11
Warning: Cannot modify header information - headers already sent by (output started at /
opt/lampp/phpPgAdmin/logout.php:11) in /opt/lampp/phpPgAdmin/logout.php on line 16
Extending XAMPP with PostgreSQL and phpPgAdmin 18/19
and add a directory with public access like it's shown here:
if (!ini_get('session.auto_start')) {
session_name('/tmp/PPA_ID');
session_start();
}
9th: The changes made in steps 7th and 8th can be replaced by a change in the
PHP configuration file “/opt/lampp/etc/php.ini”:
10th: Finally edit some settings to Apache web server's configuration file at
location “/opt/lampp/etc/httpd.conf”. Some XAMPP versions point to a
second configuration file (“/opt/lampp/etc/extra/httpd-xampp.conf”) that is
loaded in “httpd.conf”. The additional settings refer to section 3 (virtual
hosts). First, Apache needs an extension which is added to the host URL. By
that extension the phpPgAdmin is called remotely. This is achieved by
following settings:
# Alias for phpPgAdmin
# added by PJS
Alias /phpPgAdmin "/opt/lampp/phpPgAdmin"
<Directory "/opt/lampp/phpPgAdmin">
AllowOverride AuthConfig Limit
</Directory>
Furthermore, make sure that the following line is part of “httpd.conf”. It tells
Apache how to handle client requests with PHP-suffixes.
AddType application/x-httpd-php .php .php3 .php4