Extending Xampp With Postgresql and Phppgadmin: This Paper'S Intention
Extending Xampp With Postgresql and Phppgadmin: This Paper'S Intention
peter@peter-siegel.de
XAMPP is a fine adjusted software solution based on Apache Web Server, MySQL,
PHP and Perl. It has been created by the ApacheFriends Project that is hosted at
http://www.apachefriends.org. The intention behind the great idea of creating
XAMPP is a preconfigured package that is easy to handle and up-to-date. It
guarantees a minimal waste of time during installation and configuration.
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/14
pre-requisites
software components
System Linux, Distribution Debian 3.1 (Sarge)
(Kernel 2.6.8, glibc 2.3.2, Gnome 2.81, Xfree 4.3.0)
PostgreSQL Version 8.0.3
available at:
http://search.belnet.be/packages/suse/projects/postgresql/postgresql-8.0.3/9.2-i386/
PHP 5
Packages:
php5-pgsql-5.0.4-2ts.i386.rpm
Package:
readline-5.0-1.2.i586.rpm
Package:
xampp-linux-1.4.14.tar.gz
Package:
phpPgAdmin-3.5.3.tar.gz
Extending XAMPP with PostgreSQL and phpPgAdmin 3/14
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
Extending XAMPP with PostgreSQL and phpPgAdmin 4/14
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
With usage of parameter "defaults" update-rc.d will make links to start the
named service (by script "/etc/init.d/lampp") in runlevels 2345 and stop the
service in runlevels 016. These links are created and shown by following screen
output:
Extending XAMPP with PostgreSQL and phpPgAdmin 5/14
By default all the links will have sequence code 20, but this can be overridden by
supplying one or two numerical arguments.
# /opt/lampp/lampp security
# /opt/lampp/lampp security
Launching the XAMPP page in a web browser under Echnaton's IP address will
Extending XAMPP with PostgreSQL and phpPgAdmin 6/14
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 7/14
Installing PostgreSQL
Actually, the compiled binary packages for PostgreSQL 8.0.3 are only available in
'*.rpm'-format. Due to the fact that we're using PHP5, an appropriate PostgreSQL
driver should be installed. The required driver version for PHP5 is available with
Postgres Version 8.0.x, in RPM format, too. For an installation in a Debian
distribution all downloaded packages have to be converted into '*.deb'-format.
This job can be done by an "alien". Then all assembled Debian packages are
installed with "dpkg".
command line mode are needed. This request is fulfilled by the GNU Readline
Libraries to which PostgreSQL depends on. Different editing modes are provided,
well known from Emacs and Vi.
Like the predecessing step, the RPM package for "libreadline" has to be
converted and then installed.
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/
Extending XAMPP with PostgreSQL and phpPgAdmin 9/14
Switch to user “postgres” with all rights and initialize the database cluster by
following command lines:
# su - postgres
#/home/postgres/bin/initdb -D /home/postgres/data
Die Option ”-D“ gibt ein Verzeichnis an, in dem die Daten gespeichert werden.
Alternativ kann dieses Verzeichnis auch durch einen Eintrag in die Datei
”/etc/profile“ gesetzt werden:
PostgreSQL Startskript
export PGBIN=/usr/bin/
export PGDATA=~postgres/data
case "$1" in
restart)
$0 stop
$0 start
;;
reload)
su postgres -c '$PGBIN/pg_ctl -D $PGDATA -l ~postgres/logfile reload'
;;
exit 0
2nd: Create a link to the shared object library that belongs to the PostgreSQL
driver for PHP5. In XAMPP 1.4.14 the link is expected in the directoy for PHP
extensions “/opt/lampp/lib/php/extensions/no-debug-non-zts-20041030”.
Apply the following console entry:
# ln -s /usr/lib/php5/pgsql.so
/opt/lampp/lib/php/extensions/no-debug-non-zts-20041030/
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 13/14
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 14/14
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”. 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:
Furthermore, make sure that the following line is part of “httpd.conf”. It tells
Apache how to handle client requests with PHP-suffixes.