我们现在必须配置数据库,以便能够将 Webmail IMP 与 SQL 数据库一起使用。更简单的方法是使用位于以下目录下的预定义脚本/home/httpd/horde/imp/config/scripts/子目录。对于 PostgreSQL 支持,请按照以下简单步骤操作。
首先,我们必须编辑脚本文件pgsql_create.sql与 PostgreSQL 相关,位于以下目录下的/home/httpd/horde/imp/config/scripts子目录,并将其默认的运行用户名从httpd更改为www.
GRANT SELECT, INSERT, UPDATE ON imp_pref, imp_addr TO nobody; |
GRANT SELECT, INSERT, UPDATE ON imp_pref, imp_addr TO www; |
现在,我们必须为 Apache 定义名为www在我们的 PostgreSQL 数据库中,以便能够使用此用户名创建 Webmail IMP 数据库。要定义名为 httpd 的用户名www在您的数据库中,请运行 PostgreSQL 的 createuser 实用程序
[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 |
一旦 httpd 用户www已包含在 PostgreSQL 中,请以 PostgreSQL 数据库运行的用户身份登录,在本例中是postgres并插入与 PostgreSQL 相关的小脚本,以在 PostgreSQL 中自动创建 Webmail IMP 数据库。要在 PostgreSQL 中自动创建 Webmail IMP 数据库,请使用以下命令
[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 |
我们必须重启 PostgreSQL 服务器以使更改生效
[root@deep ] /# /etc/rc.d/init.d/postgresql restart |
Stopping postgresql service: [ OK ] Checking postgresql installation: looks good! Starting postgresql service: postmaster [13474] |
复制并重命名文件/home/httpd/horde/phplib/horde_phplib.inc更改为/home/httpd/php/local.inc,然后编辑新的local.inc文件,它是您的 phplib 配置文件,其中包含定义 phplib 行为的设置,并按照其说明定义您要取消注释的存储容器。
[root@deep ] /# cp /home/httpd/horde/phplib/horde_phplib.inc /home/httpd/php/local.inc |
cp: overwrite `/home/httpd/php/local.inc'? y |
编辑local.inc文件,vi/home/httpd/php/local.inc,然后取消注释并设置以下行以将 SQL 定义为您的默认数据库
/* 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. } |
最后编辑/home/httpd/php/prepend.php3文件并指定您的默认数据库类型。编辑prepend.php3文件,vi/home/httpd/php/prepend.php3然后更改以下行以将 PostgreSQL 定义为您的数据库类型
require($_PHPLIB["libdir"] . "db_mysql.inc"); |
require($_PHPLIB["libdir"] . "db_pgsql.inc"); |