Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




30.14. Configure and create Webmail IMP SQL database

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.

  1. First of all, we must edit the script file pgsql_create.sql related to PostgreSQL located under the /home/httpd/horde/imp/config/scripts subdirectory, and change its default value for the username to run as from httpd to www.
                GRANT SELECT, INSERT, UPDATE ON imp_pref, imp_addr TO nobody;
    To read:
                GRANT SELECT, INSERT, UPDATE ON imp_pref, imp_addr TO www;

  2. Now, we must define the username for Apache named www in our PostgreSQL database, to be able to create the Webmail IMP database with this username. To define the httpd username named www in your database, run the createuser utility program of PostgreSQL:
                [root@deep ] /# su postgres
                [postgres@deep /]$ createuser
            Enter 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 added

  3. Once the httpd user www has been included in PostgreSQL, log in as the user your PostgreSQL database runs as, in our case postgres and 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: [email protected]
                // Date:   Aug-29-1998
                // Notes: replace "nobody" with yours httpd username
                // Run using:  psql template1 < pgsql_create.sql
                CREATE DATABASE horde;
                \connect horde
                connecting to new database: horde
                CREATE TABLE imp_pref (
                username        	text,
                sig             		text,
                fullname        	text,
                replyto         		text,
                lang            		varchar(30)
                CREATE TABLE imp_addr (
                username        	text,
                address         	text,
                nickname        	text,
                fullname        	text
                GRANT SELECT, INSERT, UPDATE ON imp_pref, imp_addr TO www;

  4. We must restart the PostgreSQL server for the changes to take effect:
                [root@deep ] /# /etc/rc.d/init.d/postgresql restart
            Stopping postgresql service:                               [  OK  ]
                Checking postgresql installation: looks good!
                Starting postgresql service: postmaster [13474]

  5. Copy and rename the file /home/httpd/horde/phplib/ to /home/httpd/php/, then edit the new file 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.

    1.                 [root@deep ] /# cp /home/httpd/horde/phplib/ /home/httpd/php/
                cp: overwrite `/home/httpd/php/'? y

    2. Edit the file, vi /home/httpd/php/, 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 =, and var $Port =. The var $User = corresponds to your httpd username, in our case www, var $Password = corresponds to the password for the user www you have defined in PostgreSQL, and var $Port = is the IP port number used to connect to your SQL database.

  6. Finally edit the /home/httpd/php/prepend.php3 file and specifies your default database type. Edit the prepend.php3 file, vi /home/httpd/php/prepend.php3 then change the following line to define PostgreSQL as your database type:
                require($_PHPLIB["libdir"] . "");
    To read:
                require($_PHPLIB["libdir"] . "");

  Published under the terms of the Open Publication License Design by Interspire