Securing and Optimizing Linux: RedHat Edition -A Hands on Guide | ||
---|---|---|
Prev | Chapter 30. Optional component to install with Apache | Next |
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.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; |
GRANT SELECT, INSERT, UPDATE ON imp_pref, imp_addr TO www; |
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 |
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: 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 EOF |
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] |
Copy and rename the file /home/httpd/horde/phplib/horde_phplib.inc to /home/httpd/php/local.inc, then edit the new local.inc 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.
[root@deep ] /# cp /home/httpd/horde/phplib/horde_phplib.inc /home/httpd/php/local.inc |
cp: overwrite `/home/httpd/php/local.inc'? y |
Edit the local.inc file, 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. } |
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"] . "db_mysql.inc"); |
require($_PHPLIB["libdir"] . "db_pgsql.inc"); |