We must now configure our database to be able to use Webmail IMP with the SQL database. The easier method is to use the predefined scripts located under the /home/httpd/horde/imp/config/scripts/
subdirectory. For PostgreSQL support, follow the simple steps below.
First of all, we must edit the script file
pgsql_create.sqlrelated to PostgreSQL located under the/home/httpd/horde/imp/config/scriptssubdirectory, and change its default value for the username to run as fromhttpdtowww.GRANT SELECT, INSERT, UPDATE ON imp_pref, imp_addr TO nobody;To read:
GRANT SELECT, INSERT, UPDATE ON imp_pref, imp_addr TO www;Now, we must define the username for Apache named
wwwin our PostgreSQL database, to be able to create the Webmail IMP database with this username. To define the httpd username namedwwwin your database, run the createuser utility program of PostgreSQL:[root@deep ] /# su postgres [postgres@deep /]$ createuserEnter name of user to add ---> www Enter user's postgres ID or RETURN to use unix user ID: 80 -[Press Enter] Is user "www" allowed to create databases (y/n) y Is user "www" a superuser? (y/n) n createuser: www was successfully addedOnce the httpd user
wwwhas been included in PostgreSQL, log in as the user your PostgreSQL database runs as, in our casepostgresand insert the small script related to PostgreSQL to automatically create the Webmail IMP database in PostgreSQL. To automatically create Webmail IMP database in PostgreSQL, use the following commands:[root@deep ] /# cd /home/httpd/horde/imp/config/scripts/ [root@deep scripts]# su postgres [postgres@deep ] /scripts$ psql template1 < pgsql_create.sql// IMP database creation script for postgreSQL // Author: barce@lines.edu // Date: Aug-29-1998 // Notes: replace "nobody" with yours httpd username // Run using: psql template1 < pgsql_create.sql CREATE DATABASE horde; CREATEDB \connect horde connecting to new database: horde CREATE TABLE imp_pref ( username text, sig text, fullname text, replyto text, lang varchar(30) ); CREATE CREATE TABLE imp_addr ( username text, address text, nickname text, fullname text ); CREATE GRANT SELECT, INSERT, UPDATE ON imp_pref, imp_addr TO www; CHANGE EOFWe must restart the PostgreSQL server for the changes to take effect:
[root@deep ] /# /etc/rc.d/init.d/postgresql restartStopping postgresql service: [ OK ] Checking postgresql installation: looks good! Starting postgresql service: postmaster [13474]Copy and rename the file
/home/httpd/horde/phplib/horde_phplib.incto/home/httpd/php/local.inc, then edit the newlocal.incfile which is your phplib configuration file containing settings that will define the behavior of phplib, and follow its instruction to define the storage container you'll want to uncomment.[root@deep ] /# cp /home/httpd/horde/phplib/horde_phplib.inc /home/httpd/php/local.inccp: overwrite `/home/httpd/php/local.inc'? yEdit the
local.incfile, vi/home/httpd/php/local.inc, then uncomment and set the following lines to define SQL as your default database:/* To use an SQL database, uncomment and edit the following: */ class HordeDB extends DB_Sql { var $Host = 'localhost'; var $Database = 'horde'; var $User = 'www'; var $Password = 'some-password'; var $Port = '5432'; function halt($msg) { printf("<b>Database error (HordeDB):</b> %s<br>\n", $msg); } } class HordeCT extends CT_Sql { var $database_class = 'HordeDB'; // Which database class to use... var $database_table = 'active_sessions'; // and find our data in this table. }Don't forget to uncomment in this file the type of storage container you want to use for Webmail IMP. Remember to uncomment only one type. In our case we chose to use SQL. Also the parameters you must set for SQL database are the
var $User =,var $Password =, andvar $Port =. Thevar $User =corresponds to your httpd username, in our casewww,var $Password =corresponds to the password for the userwwwyou have defined in PostgreSQL, andvar $Port =is the IP port number used to connect to your SQL database.
Finally edit the
/home/httpd/php/prepend.php3file and specifies your default database type. Edit theprepend.php3file, vi/home/httpd/php/prepend.php3then change the following line to define PostgreSQL as your database type:require($_PHPLIB["libdir"] . "db_mysql.inc");To read:
require($_PHPLIB["libdir"] . "db_pgsql.inc");