<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<article>
  <title>Helios qmail installation guide</title>

  <articleinfo>
    <author>
      <firstname>Pawel</firstname>

      <surname>Foremski</surname>

      <email>pjf@gna.org</email>
    </author>

    <author>
      <firstname>Christian</firstname>

      <surname>Löschenkohl</surname>

      <email>christian.loeschenkohl@linea7.com</email>
    </author>

    <copyright>
      <year>2004</year>

      <holder>Pawel Foremski and Christian Löschenkohl</holder>
    </copyright>

    <legalnotice>
      <para>This file is free documentation.</para>
    </legalnotice>

    <abstract>
      <para>A short installation guide of Helios qmail.</para>
    </abstract>

    <pubdate>23-10-2004</pubdate>
  </articleinfo>

  <sect1>
    <title>Introduction</title>

    <para>Helios qmail has been tested on GNU/Linux and FreeBSD systems and it
    is possible that it will work also on any other UNIX like systems. If you
    have successfully installed Helios qmail on such platform, please <ulink
    url="mailto:pjf@gna.org">mail me</ulink>.</para>

    <para>If you are unfamiliar with <ulink
    url="http://ww.qmail.org/">qmail</ulink>, please read <ulink
    url="http://www.lifewithqmail.org/">Life with qmail</ulink> before trying
    to use Helios qmail.</para>
  </sect1>

  <sect1>
    <title>Requirements</title>

    <sect2>
      <title>Required software</title>

      <itemizedlist>
        <listitem>
          <para><emphasis role="bold">MySQL 4</emphasis></para>

          <para>Currently only MySQL database is supported, but PostrgreSQL
          and ODBC support is planned to be added in the future.</para>

          <para>You will need at least version 4. Simply download it from
          <ulink
          url="http://www.mysql.com/downloads/mysql-4.0.html">http://www.mysql.com/downloads/mysql-4.0.html</ulink>
          and consult it`s documentation for instructions on install
          proccess.</para>
        </listitem>

        <listitem>
          <para><emphasis role="bold">PHP 5</emphasis></para>

          <para>You will need a CLI (<firstterm>Command Line
          Interface</firstterm>) of PHP v. 5 (it will not work with PHP 4 or
          CGI version) - enable it by passing
          <emphasis>--enable-cli</emphasis> to <command>configure</command>
          script. Other requirements are:</para>

          <itemizedlist>
            <listitem>
              <para>pcntl support (<emphasis>--enable-pcntl)</emphasis></para>
            </listitem>

            <listitem>
              <para>readline support
              (<emphasis>--with-readline</emphasis>)</para>
            </listitem>

            <listitem>
              <para>MySQL support (<emphasis>--with-mysql</emphasis>)</para>
            </listitem>
          </itemizedlist>

          <para>You can get PHP from <ulink
          url="http://www.php.net/downloads.php">http://www.php.net/downloads.php</ulink>.</para>

          <para>After installing PHP download and install <emphasis
          role="bold">Mail::Mime</emphasis> library from <ulink
          url="http://pear.php.net/">PEAR</ulink>. Remember to add path to
          PEAR library dir to <emphasis>include_path</emphasis> in
          <filename>php.ini</filename> configuration file.</para>

          <note>
            <para>Remember about MySQL support, it is very important.</para>
          </note>
        </listitem>

        <listitem>
          <para><emphasis role="bold">Helios checkpassword</emphasis></para>

          <para>Get it from <ulink
          url="http://sourceforge.net/projects/helios-qmail/">http://sourceforge.net/projects/helios-qmail/</ulink>.</para>
        </listitem>

        <listitem>
          <para><emphasis role="bold">ucspi-tcp</emphasis></para>

          <para>Get it from <ulink
          url="http://cr.yp.to/ucspi-tcp/install.html">http://cr.yp.to/ucspi-tcp/install.html</ulink>.
          If compilation fails, use patch from <ulink
          url="http://www.qmail.org/moni.csi.hu/pub/glibc-2.3.1/">http://www.qmail.org/moni.csi.hu/pub/glibc-2.3.1/</ulink>.</para>
        </listitem>

        <listitem>
          <para><emphasis role="bold">daemontools</emphasis></para>

          <para>Get it from <ulink
          url="http://cr.yp.to/daemontools/install.html">http://cr.yp.to/daemontools/install.html</ulink>.
          If compilation fails, use patch from <ulink
          url="http://www.qmail.org/moni.csi.hu/pub/glibc-2.3.1/">http://www.qmail.org/moni.csi.hu/pub/glibc-2.3.1/</ulink>.</para>

          <para>Be sure to put it into your system`s start scripts. Consult
          <ulink url="http://www.lifewithqmail.org/">Life with qmail</ulink>
          on problems or use <filename>rc.daemontools</filename> script
          bundled with Helios qmail in <filename>extra/</filename> dir.</para>
        </listitem>

        <listitem>
          <para><emphasis role="bold">qmail-qfilter</emphasis></para>

          <para>Get it from <ulink
          url="http://untroubled.org/qmail-qfilter/">http://untroubled.org/qmail-qfilter/</ulink>.
          Be sure to read it`s installation instructions.</para>
        </listitem>

        <listitem>
          <para><emphasis role="bold">a C compiler and
          linker</emphasis></para>

          <para>Preferably <emphasis role="bold">GCC</emphasis> and <emphasis
          role="bold">GNU ld</emphasis>, but any other should be right. Not
          needed only if you do not want to compile qmail and spp-spf
          module.</para>
        </listitem>

        <listitem>
          <para><emphasis role="bold">GNU Bash 2.x</emphasis></para>

          <para>Get it from <ulink
          url="http://www.gnu.org/software/bash/bash.html">http://www.gnu.org/software/bash/bash.html</ulink>.</para>
        </listitem>

        <listitem>
          <para><emphasis role="bold">standard UNIX tools</emphasis></para>

          <para>For example <command>chown</command>,
          <command>chmod</command>, <command>echo</command>,
          <command>sed</command>, <command>test</command>,
          <command>cat</command>, <command>patch</command>,
          <command>useradd</command> (or <command>pw</command>) etc. You
          should already have them installed.</para>
        </listitem>
      </itemizedlist>
    </sect2>

    <sect2>
      <title>Optional software</title>

      <itemizedlist>
        <listitem>
          <para><emphasis role="bold">BINC IMAP</emphasis></para>

          <para>BINC IMAP enables IMAP service in Helios qmail. You can get it
          from <ulink
          url="http://www.bincimap.org/">http://www.bincimap.org/</ulink>.</para>
        </listitem>

        <listitem>
          <para><emphasis role="bold">stunnel 4</emphasis></para>

          <para>Enables SSL/TLS support in all Helios qmail services. Get it
          from <ulink
          url="http://www.stunnel.org/">http://www.stunnel.org/</ulink>.</para>
        </listitem>

        <listitem>
          <para><emphasis role="bold">libspf</emphasis></para>

          <para>Enables support for <ulink url="http://spf.pobox.com/">SPF
          (Sender Policy Framework)</ulink>. Get it from <ulink
          url="http://www.libspf.org/">http://www.libspf.org/</ulink>.</para>
        </listitem>
      </itemizedlist>
    </sect2>
  </sect1>

  <sect1>
    <title>Installing Helios qmail</title>

    <para>If you are ready for the install proccess, run
    <command>configure</command> script found in Helios qmail package. It will
    check your system for dependencies and report any problems if they occurs,
    then it will generate <command><filename>install</filename></command>
    script, which can be run to finally install Helios qmail on your
    system.</para>

    <note>
      <para>Build system of Helios qmail supports VPATH-like builds</para>
    </note>

    <sect2>
      <title>The <command>configure</command> script</title>

      <para><command>configure</command> has several options, but usually you
      should care only about following switches:</para>

      <itemizedlist>
        <listitem>
          <para><emphasis>--with-me=DOMAIN</emphasis></para>

          <para>Tells Helios qmail the FQDN (Fully Qualified Domain Name) of
          the machine your are installing it on.</para>
        </listitem>

        <listitem>
          <para><emphasis>--with-ips=IP1[,IP2,...]</emphasis> and
          <emphasis>--without-ips=IP1[,IP2,...]</emphasis></para>

          <para>qmail tries to find IP addresses of machine it is running on
          automatically by getting them from all network interfaces. However,
          if you are behind firewall and/or have some port forwarding, you
          should let it know about it by passing your additional IP addresses
          in <emphasis>--with-ips option</emphasis>. If you want some IPs to
          not be treated as local, pass them in <emphasis>--without-ips
          option</emphasis>.</para>
        </listitem>
      </itemizedlist>

      <para>You can get list of all <command>configure</command> options by
      invoking it with <emphasis>--help</emphasis> option.</para>

      <para>If <command>configure</command> will run without any errors, it
      will print out a summary and generate the <command>install</command>
      script in the current directory. If everything will be OK, go
      further.</para>
    </sect2>

    <sect2>
      <title>The <command>install</command> script</title>

      <para><command>install</command> script is generated by
      <command>configure</command> and it builds the whole system and installs
      it on your hard drive. During run it creates <filename>tmp</filename>
      dir in the current directory, so if you do not want to clutter your
      source code, you can <command>cd</command> into other, more adequate
      directory.</para>

      <para>It will extract, patch and compile qmail source (if you did not
      pass <emphasis>--without-qmail</emphasis> to
      <command>configure</command>), install all scripts, libraries and
      configuration files and build spp-spf module if you have chosen to
      enable it. If you have installed Helios qmail before, and already have
      some configuration files, it will add <emphasis>.new</emphasis>
      extension to all new configuration files to prevent your old
      configuration from overwriting. However, it will overwrite all old
      programs and scripts.</para>

      <para>If you are ready, simply run <command>install</command>
      script.</para>
    </sect2>

    <sect2>
      <title>Post-install steps after first installation</title>

      <sect3>
        <title>Database initialization</title>

        <para>You will have to init your database with correct data structure
        before using Helios qmail. A correct schema is provided in
        <filename>setup/dbschema.sql</filename>, but you can also use
        <command>setup/initdb-mysql</command> script to do it for you.</para>

        <para>Probably you will be interested in using these options of init
        script:</para>

        <itemizedlist>
          <listitem>
            <para><emphasis>-p, --password=PASSWORD</emphasis></para>

            <para>It will be the password of user with read access to the
            database which Helios qmail will use eg. for getting user
            information. Default: <literal>secret</literal>.</para>
          </listitem>

          <listitem>
            <para><emphasis>-P, --adminpassword=PASSWORD</emphasis></para>

            <para>It will be the password of user with full access to the
            database which Helios qmail will use eg. for writing lastlogin IP
            and time. Default: <literal>secret</literal>.</para>
          </listitem>

          <listitem>
            <para><emphasis>-a,
            --mysqladminpassword=PASSWORD</emphasis></para>

            <para>Password of MySQL administrator (default: root). If you do
            not have password, do not use this option.</para>
          </listitem>
        </itemizedlist>

        <para>You can get list of all <command>initdb-mysql</command> options
        by invoking it with <emphasis>--help</emphasis> option.</para>

        <para>After initializing your database check it`s connectivity and
        modify <emphasis>connectionstring</emphasis> and
        <emphasis>popconnectionstring</emphasis> in
        <filename>/var/qmail/control/qmailconfig</filename> file.</para>
      </sect3>

      <sect3>
        <title>Providing a server certificate</title>

        <para>If you have chosen to enable SSL/TLS support (using <emphasis
        role="bold">stunnel</emphasis>), you will have to provide a server
        certificate and key in
        <filename>/var/qmail/control/servercert.pem</filename> file. Simply
        copy it there, if you have such, or use
        <command>setup/servercert-gen</command> script to generate self-signed
        certificate. You can see it`s options by invoking it with
        <emphasis>--help</emphasis> option.</para>

        <note>
          <para><filename>servercert.pem </filename>should be should be owned
          by <emphasis>qmaild:nofiles</emphasis> and has permissions set to
          <emphasis>640</emphasis></para>
        </note>
      </sect3>

      <sect3>
        <title><command>tcpserver</command>`s rules</title>

        <para>You will have to compile
        <filename>/var/qmail/control/smtp-tcprules</filename> file into a
        <emphasis>.cdb</emphasis> file to provide rules for SMTP service
        served by <command>tcpserver</command>. Simply edit this file (only if
        you want) and type <command>/var/qmail/helios/qmailctl.sh
        cdb</command>.</para>
      </sect3>

      <sect3>
        <title>Configuration</title>

        <para>See the second chapter of the Helios qmail manual and modify
        your configuration files if needed.</para>
      </sect3>
    </sect2>

    <sect2>
      <title>Starting Helios qmail</title>

      <para>If you are absolutely sure that your Helios qmail is properly
      installed and configured, you can link all directories from
      <filename>/var/qmail/supervise/</filename> to
      <filename>/service/</filename> eg. by typing <command>ln -s
      /var/qmail/supervise/* /service/</command>. If daemontools is running,
      Helios qmail should be started automatically in max. 5 seconds.
      Otherwise try to restart daemontools manually.</para>

      <para>If something goes wrong, see system logs (usually
      <filename>/var/log/maillog</filename>) or output of <command>ps aux |
      more</command> (look for <emphasis>readproctitle service
      errors</emphasis>, where <emphasis>readproctitle service errors:
      ...................................</emphasis> is good and e.g.
      <emphasis>readproctitle service errors: Mutlilog cannot write</emphasis>
      is bad).</para>
    </sect2>
  </sect1>
</article>