\documentclass{article}
\usepackage{ulem}
\usepackage{graphicx}
\usepackage{hyperref}
\pagestyle{headings}
\begin{document}
\part{Installing Horde Groupware Webmail Edition on CentOS 5}
<a href="http://www.horde.org/webmail/">Horde Groupware Webmail Edition</a> is a free, enterprise ready, browser based communication suite. Users can read, send and organize email messages and manage and share calendars, contacts, tasks and notes with the standards compliant components from the Horde Project. Horde Groupware Webmail Edition bundles the separately available applications IMP, Ingo, Kronolith, Turba, Nag and Mnemo.

\section{Versions}
\begin{itemize}
\item CentOS 5.0 i386 (OS)


\item Horde Groupware Webmail Edition 1.0.3 (October 2 2007)


\item Apache 2.2.3 (http server)


\item MySQL 5.0.22 (db server)


\item Postfix 2.3.3 (mail server)


\item Dovecot 1.0 (IMAP server)


\end{itemize}
(Although this how to has been made with the above versions, it may work just the same for newer versions of Horde)

\section{Set up your host name and address}
\textit{This is only necessary if you didn't do it at installation.}

Use system-config-network-tui to set up IP, Netmask and Gateway:

<pre><code>
system-config-network-tui
</code></pre>
Edit /etc/sysconfig/network and set your hostname:

<pre><code>
NETWORKING=yes
NETWORKING\_IPV6=yes
HOSTNAME=yourhostname.yourdomain.com
</code></pre>
Edit /etc/resolv.conf and add your DNS servers:

<pre><code>
nameserver 208.67.222.222
nameserver 208.67.220.220
</code></pre>
Edit /etc/hosts to something like this, according to your system settings:

<pre><code>
\# Do not remove the following line, or various programs
\# that require network functionality will fail.
127.0.0.1         localhost.localdomain        localhost
192.168.0.100     yourhostname.yourdomain.com  yourhostname
::1               localhost6.localdomain6      localhost6
</code></pre>
Restart network:

<pre><code>
service network restart
</code></pre>
If your using GUI interface (like gnome), you may need to restart it:

<pre><code>
init 6
</code></pre>
\section{Installing prerequisites}
<pre><code>
yum install -y gettext httpd mysql mysql-server dovecot postfix system-switch-mail perl

yum install -y php php-mysql php-xml php-imap php-mbstring php-mcrypt php-pecl-Fileinfo php-pecl-memcache  
               php-pear-DB php-pear-File php-pear-Log php-pear-Mail-Mime php-pear-Auth-SASL php-pear-Date  
               php-pear-HTTP-Request php-pear-Mail php-pear-Net-Sieve php-pear-Net-Socket php-pear-Net-SMTP  
               php-pear-MDB2-Driver-mysql php-gd php-xmlrpc php-soap php-pecl-json

yum install -y php-pear-Date-Holidays            <-- (for now, this package is available in the EPEL[1] repo)

yum install -y openssl mod\_ssl crypto-utils perl-Net-SSLeay         <--(for https secure browsing)

yum install -y php-devel gcc      <--(if you want to install extra pecl modules - PS: use 'pear install pecl/modulename')
</code></pre>
[1] About EPEL repo: <a href="http://fedoraproject.org/wiki/EPEL">http://fedoraproject.org/wiki/EPEL</a><br />
Note: It is possible that yum install may not find any package when installing a php- or http- extensions. We may have to exclude php* and http* from yum.conf (usually in /etc/yum.conf) by renaming php* and http* and then running 'yum install'. This makes it work. Reference: <a href="http://programmingbulls.com/pecl-install">Install PECL</a>

\section{Configuring Postfix and Dovecot}
Turn off sendmail:

<pre><code>
service sendmail stop
chkconfig sendmail off

system-switch-mail
(select postfix)
</code></pre>
Configure Postfix:

<pre><code>
postconf -e 'home\_mailbox = Maildir/'
</code></pre>
Edit /etc/dovecot.conf and add the following to the end of the file:

<pre><code>
\# to allow the creation of mail subfolders
mail\_location = maildir:\textasciitilde{}/Maildir

\# Enable IMAP protocol
protocols = imap
</code></pre>
If using <a href="https://wiki.horde.org/CentOS">CentOS</a> x86\_64, temporary fix for this <a href="http://bugs.centos.org/view.php?id=2651">bug</a>

<pre><code>
login\_process\_size = 64
</code></pre>
To configure the rest of postfix, such as domain name and secure connections, take a look at this nice tutorial: <a href="http://fedorasolved.org/server-solutions/postfix-mail-server">http://fedorasolved.org/server-solutions/postfix-mail-server</a>

\section{Start services}
<pre><code>
service httpd restart
chkconfig httpd on

service postfix restart
chkconfig postfix on

service dovecot restart
chkconfig dovecot on

service mysqld restart
chkconfig mysqld on
</code></pre>
Configure mysqld root password:

<pre><code>
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h yourhostname.yourdomain.com password 'new-password'
</code></pre>
\section{Download Horde Groupware Webmail Edition and extract it}
Get the latest stable version of Horde Groupware Webmail Edition from <a href="http://www.horde.org/download/app/?app=webmail">http://www.horde.org/download/app/?app=webmail</a>.

Extract files and rename folder:

<pre><code>
tar zxf horde-webmail-*.tar.gz -C /var/www/html/
mv /var/www/html/horde-*/ /var/www/html/horde/
</code></pre>
\section{Creating database and tables in MySQL}
\subsection{For those who want everything in UTF-8}
<a href="https://wiki.horde.org/MySQL">MySQL</a> default charset is "latin1" (or ISO-8859-1).

It happens that keeping evertyhing in UTF-8 is a good practice and prevent a lot of trouble in the future, as mentioned <a href="http://www.oreillynet.com/onlamp/blog/2006/01/turning_mysql_data_in_latin1_t.html">here</a>.

If you whish to do so, before you even create your db tables for horde, turn your <a href="https://wiki.horde.org/MySQL">MySQL</a> installation to UTF-8, inserting these lines into your \textbf{/etc/my.cnf} file:

<pre><code>
[mysqld]
collation\_server=utf8\_general\_ci
character\_set\_server=utf8
init\_connect="SET NAMES 'utf8'"

[client]
default\_character\_set=utf8
</code></pre>
If you do not want your DB to be UTF-8, just leave the my.cnf as it is.

\subsection{Run the setup.php script:}
<pre><code>
cd /var/www/html/horde/scripts/
./setup.php
</code></pre>
If asked, choose /horde.

Press 1; choose mysql; Persistent connection: 0; Username horde; Choose a password for mysql-user-horde; Unix sockets; Location /var/lib/mysql/mysql.sock; DB name horde; internally used charset ut-8 or iso-8859-1 (depends on how you have configured your mysql encoding - see above)

Press 2; yes; root; root-mysql-password.

Press 3; specify an existing IMAP user to have horde administration permissions (i.e. your current linux user).

\subsection{Create user horde in MySQL and grant horde DB the proper permissions}
Edit a text file and change the password for the same as in Step 1 above:

<pre><code>
USE mysql;

REPLACE INTO user (host, user, password)
    VALUES (
        'localhost',
        'horde',
-- IMPORTANT: Change this password!
        PASSWORD('password\_for\_mysql\_horde\_user')
);

REPLACE INTO db (host, db, user, select\_priv, insert\_priv, update\_priv,
                 delete\_priv, create\_priv, drop\_priv, index\_priv)
    VALUES (
        'localhost',
        'horde',
        'horde',
        'Y', 'Y', 'Y', 'Y',
        'Y', 'Y', 'Y'
);

-- Make sure that priviliges are reloaded.
FLUSH PRIVILEGES;
</code></pre>
Save the file as createuser.mysql (or something else) and load it as mysql stdin:

<pre><code>
mysql --user=root --password=mysqlrootpassword < createuser.mysql
</code></pre>
\section{Configure Apache and PHP}
Add a "horde.conf" file to /etc/httpd/conf.d:

<pre><code>
\#
\# Horde
\#

Alias /horde /var/www/html/horde

<Directory /var/www/html/horde>
	\# Uncomment the following 3 lines to make Horde locally accessible only
	\#Order Deny,Allow
	\#Deny from all
	\#Allow from 127.0.0.1

	Options +FollowSymLinks

	\# horde.org's recommended PHP settings:
	php\_admin\_flag safe\_mode off
	php\_admin\_flag magic\_quotes\_runtime off
	php\_flag session.use\_trans\_sid off
	php\_flag session.auto\_start off
	php\_admin\_flag file\_uploads on
	php\_value session.gc\_divisor 10000
	php\_value session.gc\_probability 1
	\# Optional - required for weather block in Horde to function
	php\_admin\_flag allow\_url\_fopen on

	\# If horde dies while trying to handle large email file attachments,
	\#  you are probably hitting PHP's memory limit.  Raise that limit here,
	\#  but use caution
	\# Set to your preference - memory\_limit should be at least 32M
	\#  and be greater than the value set for post\_max\_size
	\#php\_value memory\_limit 32M
	\#php\_value post\_max\_size 20M
	\#php\_value upload\_max\_filesize 10M

	\# /usr/share/pear is needed for PEAR. /var/www/html/horde is needed for Horde itself
	\# TODO: Set an appropriate include\_path, too. Might even increase speed a bit.
	php\_admin\_value open\_basedir "/var/www/html/horde:/var/www/html/horde/config:/usr/share/pear:/tmp"
	php\_admin\_flag register\_globals off
</Directory>

<Directory /var/www/html/horde/config>
	Order Deny,Allow
	Deny from all
</Directory>

\# Deny access to the test.php files except from localhost
<LocationMatch "\^{}/horde/(.*/)?test.php">
	Order Deny,Allow
	Deny from all
	Allow from 127.0.0.1
</LocationMatch>
</code></pre>
Change horde.conf permission:

<pre><code>
chmod 0644 -v /etc/httpd/conf.d/horde.conf 
</code></pre>
Increase memory\_limit option in /etc/php.ini to 64MB or higher (128MB is recommended):

<pre><code>
memory\_limit = 64M
</code></pre>
Restart httpd:

<pre><code>
service httpd restart
</code></pre>
\section{Check if everything is alright}
Open the following address in your browser:

<pre><code>
http://localhost.localdomain/horde/test.php
</code></pre>
\section{Security configuration}
Secure config files:

<pre><code>
chown apache:root -R /var/www/html/horde/config
chown apache:root -R /var/www/html/horde/*/config
chmod -R go-rwx /var/www/html/horde/config
chmod -R go-rwx /var/www/html/horde/*/config
</code></pre>
Secure scripts:

<pre><code>
chown -R root:root /var/www/html/horde/scripts
chown -R root:root /var/www/html/horde/*/scripts
chmod -R go-rwx /var/www/html/horde/scripts
chmod -R go-rwx /var/www/html/horde/*/scripts
</code></pre>
Secure test.php:

<pre><code>
chmod a-rwx /var/www/html/horde/test.php
chmod a-rwx /var/www/html/horde/*/test.php
</code></pre>
\section{Finishing configuration}
Open the following url in your browser and log into horde with the administrator user (defined above in Option 2 when creating databases):

<pre><code>
http://localhost.localdomain/horde
</code></pre>
(PS: use full URL address, with host and domain name)<br />
(PS2: Remember to check \$conf['cookie']['path'] = '/horde'; in horde/config/conf.php to match the path you use to access horde on your server)

Fell free to change other options, as you like. The good thing about Horde Groupware Webmail Edition is it comes pretty much configured and ready for use!

Remember to restart \textbf{httpd} after you make changes:

<pre><code>
service httpd restart
</code></pre>
\section{Performance}
\subsubsection{Memcached}
Memcached is a great performance utility. In order to use it you will need the pecl memcache extension and the memcached package:

<pre><code>
yum install php-pecl-memcache memcached
</code></pre>
Then, configure the memcached by editing the file /etc/sysconfig/memcached:

<pre><code>
PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="512"        <- Amount of memory to use (in MB)
OPTIONS=""
</code></pre>
Turn on the service on the default runlevel and start it:

<pre><code>chkconfig memcached on
service memcached start
</code></pre>
Finish configurarion on Horde -> Administration -> Setup -> Horde -> Cache System (and) Memcache Server.

\subsubsection{<a href="https://wiki.horde.org/MySQL">MySQL</a>}
You could try to increase mysql performance by enabling query cache feature.

Edit your /etc/my.cnf and add the following under <a href="https://wiki.horde.org/mysqld">mysqld</a>:

<pre><code>
query-cache-size=50M  (or whatever you think is enough)
</code></pre>
Run the exact same queries and then, on mysql console, check on query cache status:

<pre><code>
mysql> show status like '\%qcache\%';
</code></pre>
\end{document}
