2011-09-08

Installing Horde On CentOS6

Progress is being made on first-class integration between OpenGroupware Coils and Horde 4; that is, using Horde 4 as a Web 2.0 / AJAX front-end to the various services provided by OpenGroupware Coils.  This integration is primarily implemented using a custom JSON-RPC protocol bundle designed specifically for integration with Horde.  This article walks through the install to achieve a basic Horde installation.  Subsequent articles will document how to achieve OpenGroupware Coils integration.

This installation procedure assumes:
  • You'll be using a memcache instance for caching.
  • A PostgreSQL database for server meta-data and Horde user preferences;  probably the same PostgreSQL instance you use for your OpenGroupware databse. But for this example we are just setting up a local PostgreSQL instance.  We'll cover installing OpenGroupware Coils on CentOS6 soon.
  • You'll be installing Horde into a virtual host in the folder "/srv/www/vhosts/horde".
  • The horde install will have it's own PEAR repository as separated from the system PEAR repository as possible.
  • The ImageMagick packages will be installed to allow Horde to manipulate images (such as creating thumbnails of image attachments to e-mail).
  • GPG will be installed in order to support encrypted e-mails and notes.
  • We are starting with a clean CentOS6 install of the basic server profile.
  • SELinux is disabled (edit /etc/sysconfig/selinux). In a subsequent article re-enabling SELinux will be documented. 
  • To access this instance remotely the TCP/80 port must be allowed via the host's firewall configuration. If you intend to enable TLS/SSL (secure) access port TCP/443 must also be allowed [on CentOS6 use the system-config-firewall-tui to perform basic firewall configuration configuration, production systems should consider using a more sophisticated tool such as FWBuilder].
Step#1 Install the required packages.
yum install php-devel php-pear make gcc libidn-devel pam-devel pcre-devel postgresql-devel libidn-devel memcached-devel memcached libmemcached zlib-devel cyrus-sasl-devel ImageMagick-devel ImageMagick php-ldap php-intl php-mbstring php-pdo php-pecl-apc php-pgsql php-soap php-tidy php-xml php-xmlrpc php-pecl-memcache libtidy-devel
Step#2 Create the vhost directory and initialize the PEAR package database.
mkdir -p /srv/www/vhosts/horde
pear config-create  /srv/www/vhosts/horde /srv/www/vhosts/horde/pear.conf
pear -c /srv/www/vhosts/horde/pear.conf install pear
Step#3 Add the Horde channel to the PEAR configuration and initialize the Horde role.  The last "run-scripts" command will prompt you for the root of the Horde installation; enter "/srv/www/vhosts/horde".
/srv/www/vhosts/horde/pear/pear -c  /srv/www/vhosts/horde/pear.conf channel-discover pear.horde.org
/srv/www/vhosts/horde/pear/pear -c /srv/www/vhosts/horde/pear.conf  install horde/horde_role
/srv/www/vhosts/horde/pear/pear -c  /srv/www/vhosts/horde/pear.conf run-scripts horde/Horde_Role
Step#4 Set the timezone in your php.ini file Edit the /etc/php.ini to set the date.timezone property to the server's local timezone.  For example: "date.timezone=America/Detroit"

Step#5 Install the re2c package from the DAG repo.  You can optionally add the DAG repo to your system or just pull this one package.  re2c is used by the PHP interpreter to efficiently compile regular expressions.
curl --location -o /tmp/re2c-0.13.5-1.el6.rf.x86_64.rpm http://mandril.creatis.insa-lyon.fr/linux/dag/redhat/el6/en/x86_64/dag/RPMS/re2c-0.13.5-1.el6.rf.x86_64.rpm
rpm -Uvh /tmp/re2c-0.13.5-1.el6.rf.x86_64.rpm
Step#6 As in Step#5 you can add the DAG repo to your system or just pull the two packages necessary to build the geoip module.  Horde will use this to relate hosts to geographic regions.
curl --location -o /tmp/geoip-devel-1.4.6-1.el6.rf.x86_64.rpm http://mandril.creatis.insa-lyon.fr/linux/dag/redhat/el6/en/x86_64/dag/RPMS/geoip-devel-1.4.6-1.el6.rf.x86_64.rpm
curl --location -o /tmp/geoip-1.4.6-1.el6.rf.x86_64.rpm http://mandril.creatis.insa-lyon.fr/linux/dag/redhat/el6/en/x86_64/dag/RPMS/geoip-1.4.6-1.el6.rf.x86_64.rpm
rpm -Uvh  /tmp/geoip-1.4.6-1.el6.rf.x86_64.rpm /tmp/geoip-devel-1.4.6-1.el6.rf.x86_64.rpm
pecl install geoip
echo "extension=geoip.so" > /etc/php.d/geoip.ini
Step#7 Build and install the Imagick extension which will allow Horde to efficiently manipulate images.
pecl install Imagick
echo "extension=imagick.so" > /etc/php.d/imagick.ini
Step#8 Build the tidy module which Horde can use to sanitize HTML content.
pecl install tidy
echo "extension=tidy.so" > /etc/php.d/tidy.ini
Step#9 Build the lzf module which allows Horde to efficiently compress and decompress data.
pecl install lzf
echo "extension=lzf.so" > /etc/php.d/lzf.ini
Step#10 Install the PEAR packages. In this example we manually install several PEAR modules first to verify that PEAR installation is working and because we want to ensure that these optional modules get installed as we will be depending on their existence in this setup.  Particularly the Net_Sieve and Horde_Memcache do not install my default./srv/www/vhosts.
/srv/www/horde/pear/pear -c /srv/www/vhosts/horde/pear.conf install HTTP_Request
/srv/www/vhosts/horde/pear/pear -c /srv/www/vhosts/horde/pear.conf install Net_SMTP
/srv/www/vhosts/horde/pear/pear -c /srv/www/vhosts/horde/pear.conf install Net_Sieve
/srv/www/vhosts/horde/pear/pear -c /srv/www/vhosts/horde/pear.conf install Auth_SASL
/srv/www/vhosts/horde/pear/pear -c /srv/www/vhosts/horde/pear.conf install Net_DNS2
/srv/www/vhosts/horde/pear/pear -c /srv/www/vhosts/horde/pear.conf install horde/horde
/srv/www/vhosts/horde/pear/pear -c /srv/www/vhosts/horde/pear.conf install horde/Horde_Memcache
/srv/www/vhosts/horde/pear/pear -c /srv/www/vhosts/horde/pear.conf install horde/imp
/srv/www/vhosts/horde/pear/pear -c /srv/www/vhosts/horde/pear.conf install horde/turba
/srv/www/vhosts/horde/pear/pear -c /srv/www/vhosts/horde/pear.conf install horde/kronolith
/srv/www/vhosts/horde/pear/pear -c /srv/www/vhosts/horde/pear.conf install horde/mnemo
/srv/www/vhosts/horde/pear/pear -c /srv/www/vhosts/horde/pear.conf install horde/nag
/srv/www/vhosts/horde/pear/pear -c /srv/www/vhosts/horde/pear.conf install horde/ingo
Step#11 Initialize the configuration.
cp  /srv/www/vhosts/horde/config/conf.php.dist  /srv/www/vhosts/horde/config/conf.php
setfacl -m u:apache:rw /srv/www/vhosts/horde/config/conf.php
touch /srv/www/vhosts/horde/imp/config/conf.php
touch /srv/www/vhosts/horde/ingo/config/conf.php
touch /srv/www/vhosts/horde/turba/config/conf.php
touch /srv/www/vhosts/horde/kronolith/config/conf.php
touch /srv/www/vhosts/horde/nag/config/conf.php
touch /srv/www/vhosts/horde/mnemo/config/conf.php
setfacl -m u:apache:rw /srv/www/vhosts/horde/imp/config/conf.php
setfacl -m u:apache:rw /srv/www/vhosts/horde/ingo/config/conf.php
setfacl -m u:apache:rw /srv/www/vhosts/horde/turba/config/conf.php
setfacl -m u:apache:rw /srv/www/vhosts/horde/kronolith/config/conf.php
setfacl -m u:apache:rw /srv/www/vhosts/horde/nag/config/conf.php
setfacl -m u:apache:rw /srv/www/vhosts/horde/mnemo/config/conf.php
Step#12 Enable name based virtual hosting.
Edit the /etc/httpd/conf/httpd.conf file and uncomment the line reading "NameVirtualHost *:80".

Step#13  Create a virtual host entry for the Horde instance. If you have a server-name / domain-name you should substitute that for "horde.example.com". Otherwise if this instance is merely for testing/development adding horde.example.com to your workstation's /etc/hosts file should be sufficient to allow you to access the instance. The domain "example.com" will never be issued as an actual domain (see RFC2606) so it is safe to use for development deployments.  Depending on your site's policies you may want to configure custom logging for this virtual host.
(cat <<EOF
<virtualhost *:80>
    ServerAdmin webmaster@horde.example.com
    ServerName horde.example.com
    ServerAlias horde
    DocumentRoot /srv/www/vhosts/horde
    <directory /srv/www/vhosts/horde>
       Options Indexes Includes FollowSymLinks
       Order allow,deny
       Allow from all
    </directory>
   php_value include_path /srv/www/vhosts/horde/pear/php
   SetEnv PHP_PEAR_SYSCONF_DIR /srv/www/vhosts/horde
</virtualhost>
EOF
) > /etc/httpd/conf.d/x-vhost-horde.conf
Step#14 Start the web server (Apache) and Memcache daemon.
service httpd start
chkconfig httpd on
service memcached start
chkconfig memcached on
Step#15 You should now be able to hit the CentOS6 instance with your web-browser and automatically be logged in as the Horde administrator!  Go the the Administration / Configuration page via the left-hand menu and you should see a list of the installed Horde applications as well as the first level of Horde modules that provide services to those applications (such as "Horde_Alarm", "Horde_Activesync", etc...).  If you don't see those additional Horde modules listed then something went wrong with your PEAR installation; start over and carfully watch the output of the commands for errors or warnings.



Step#16 Generate new configurations for all applications; to perform this function click the "Update all configuration" button. This will fill in the various conf.php files we created in Step#11.

Step#17 Provision a PostgreSQL database for use by the Horde instance. Caution: If you are reusing a PostgreSQL instance from other applications do not perform the "service postgresql initdb" command.
yum install postgresql-server
service postgresql initdb
service postgresql start
sudo  -u postgres createuser --no-password --no-createdb --no-createrole --no-superuser horde4
sudo  -u postgres createdb -E utf-8 -O horde4 horde4
Once the database is provision you need to allow the Horde instance to connect to the database. For simplicity of this example we are connecting to the instance of PostgreSQL on the localhost so we will simply change the configuration to trust local connections. For production deployments at least a password should be configured for the connection. To grant access edit the /var/lib/pgsql/data/pg_hba.conf file and change "ident" to "trust" on the line reading "host    all         all         127.0.0.1/32".  Then restart the PostgreSQL database so that it rereads this file: "service postgresql restart"

Step#18 Configure the database connectivity of the Horde instance. Now that Horde is up and running subsequent configuration is simple. Select Administration / Configuration from the left-hand menu. From the list of applications select "Horde" and then choose the "Database" tab.
  • For database type choose "PostgreSQL"
  • Check the box enabling persistent connections.
  • For "username" enter "horde4"
  • Change protocol to "TCP/IP"
  • For "hostspec" and "port" enter "127.0.0.1" and "5432".
  • For "database" enter "horde4".
  • Leave "charset" as "utf-8" and "splitread" as "Disabled"
  • Once the form is filled in click the "Generate Horde Configuration"

Step#19: Now click the "Update all DB schemas" button; this will initialize the database with the required tables.  Every time applications are updated this button will allow the database schema to be automatically updated. This first time you initialize Horde you should perform this operation until no more database schema error or notices appear - typically this requires performing this operation twice.
Step#20The last steps involved in configuring the base Horde configuration is to enable a caching system to accelerate performance. For this example we are using the memcache service we enabled in Step#14. Navigate to Administration / Configuration, select the Horde application, and then choose the Memcache Server tab.
  • Change the status to "Enabled"
  • For "hostspec" and "port" enter "127.0.0.1" and "11211".  These are the default Memcache configuration parameters.
  • Enable persistent connections by checking the "persistent" box
  • Change to the "Cache System" tab.
  • For the cache system driver select "Use a Memcache server".
  • Click the "Generate Horde Configuration" button.
Your Horde configuration is now configured with database connectivity and an active caching system.  In subsequent articled the procedure for configuring specific applications and enabling OpenGroupware Coils integration.

1 comment: