====== Installation PostgrSQL Datenbank ====== ===== Vorbereitung ===== Das Dokument bezieht sich auf die Installation der Opensource-Datenbank [[http://www.postgresql.org/|PostgreSQL]] in Version 8.x.\\ Als Erstes lädt man sich die Sourcen der benötigten Komponenten herunter: * postgresql-8.x.x.tar.bz2 von [[http://www.postgresql.org/ftp/source/|PostgreSQL.org]] * phpPgAdmin-4.x.x.tar.gz von [[http://phppgadmin.sourceforge.net/|phpPgAdmin@sourceforge.net]] Nach dem Download werden alle Archive in einem temporären Verzeichnis ausgepackt.\\ * **tar xvzpf archiv.tar.gz** oder **tar xvjpf archiv.tar.bz2** ===== PostgreSQL kompilieren ===== Im Folgenden wird davon ausgegangen, daß die Installation in das Verzeichnis **/usr/local/pgsql** erfolgt. cd postgresql-8.x.x LDFLAGS="-L/opt/apache/lib -lssl" ./configure --enable-thread-safety --with-perl --with-openssl --with-gnu-ld \ --without-readline --with-includes=/var/tmp/openssl-0.9.xx/include make make install adduser postgres mkdir /usr/local/pgsql/data chown postgres /usr/local/pgsql/data su - postgres /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start /usr/local/pgsql/bin/createdb testdb Mit den letzten 3 Befehlen wird die Datenbank initialisiert, die Prozesse gestartet und eine Datenbankinstanz namens testdb erstellt. Gestoppt werden die Prozesse mit dem folgenden Befehl: /usr/local/pgsql/bin/pg_ctl stop -D /usr/local/pgsql/data -m smart Wenn man nur lokale Verbindungen benötigt, beispielsweise für Webmail (Squirrelmail, IMAPd), sollte man folgende Zeilen in **/usr/local/pgsql/data/pg_hba.conf** anpassen. Aus @authcomment@ # TYPE DATABASE USER CIDR-ADDRESS METHOD @remove-line-for-nolocal@# "local" is for Unix domain socket connections only @remove-line-for-nolocal@local all all @authmethod@ # IPv4 local connections: host all all 127.0.0.1/32 @authmethod@ # IPv6 local connections: host all all ::1/128 @authmethod@ wird dann # CAUTION: Configuring the system for local "trust" authentication allows # any local user to connect as any PostgreSQL user, including the database # superuser. If you do not trust all your local users, use another # authentication method. # TYPE DATABASE USER CIDR-ADDRESS METHOD # "local" is for Unix domain socket connections only # local all all md5 # IPv4 local connections: # host all all 127.0.0.1/32 md5 # IPv6 local connections: # host all all ::1/128 md5 local all all trust local maildb sqmail trust host maildb sqmail 127.0.0.1/32 md5 host all 127.0.0.1 255.0.0.0 trust host all 0.0.0.0 0.0.0.0 reject ===== phpPgAdmin installieren ===== Da es sich bei dieser Software um ein Webinterface zur Administration von PostgrSQL handelt, welches komplett in PHP erstellt wurde, muß man das Archiv nur in ein Verzeichnis kopieren und die Konfiguraitionsdateien entsprechend anpassen. Außerdem muß in der httpd.conf des Webservers folgender Abschnitt hinzugefügt werden: Alias /pgsql "/usr/share/phpPgAdmin" Options Indexes FollowSymLinks AllowOverride AuthConfig Indexes Im obigen Beispiel wurde die Software in ein Verzeichnis unter /usr/share kopiert. Jetzt müssen in der Datei /usr/share/phpPgAdmin/conf/config.inc.php nur noch die Pfade angepaßt werden. Wenn diese Datei nicht existiert, kann man auch einfach die im selben Verzeichnis liegende mitgelieferte config.inc.php-dist nehmen und entsprechend umbenennen. Aus $conf['servers'][0]['pg_dump_path'] = '/usr/bin/pg_dump'; $conf['servers'][0]['pg_dumpall_path'] = '/usr/bin/pg_dumpall'; wird $conf['servers'][0]['pg_dump_path'] = '/usr/local/pgsql/bin/pg_dump'; $conf['servers'][0]['pg_dumpall_path'] = '/usr/local/pgsql/bin/pg_dumpall'; Außerdem kann man noch den Parameter "extra_login_security" von true auf false stellen. Dies sollte aber nur dann erfolgen, wenn man in der Datei pg_hba.conf nur lokale Verbindungen zuläßt (s.o.)