• HOWTO: setting up DAViCal on CentOS 5.5

    Posted on February 19th, 2011 Nattl 2 comments

    I use calendars a lot: I use MS Exchange at work which I can also access with my iPhone. At home I use the Gmail calendar service which also works quite well with Apples iCal and the iPhone. However I always disliked the idea that Google knows all about my private schedules and appointments. So I decided to setup my own calendar service on a CentOS server. There are several iCalendar projects available, some of them open source, others commercial. As it was clear I would only go with an open source project I looked at several candidates and then I found out about DAViCal, a php/postgresql based service that looked good enough to give it a try.

    Last night I set up a DAViCal server on my new CentOS box. As it was not as trivial as I thought in the beginning, I gonna share my experience here.

    The HOWTO provided by John M. Simpson was a big help, however it is a little bit outdated so not everything worked out of the box as described. As there are some pitfalls during installation that cost me quite some time to puzzle out what was wrong I thought I provide a little HOWTO guide. All the tasks where made as superuser!

    I started on a clean set up CentOS machine with SSH access only. So the first step is to install the software you need to run DAViCal. You need an Apache with PHP and a PostgreSQL database. Using the yum package manager, the installation is easy peasy:

    Apache & PHP:

    $> yum install httpd php php-pgsql

    PostgreSQL database:

    $> yum install postgresql postgresql-server postgresql-libs postgresql-devel

    If you haven’t installed yet, it could not be wrong to have the GCC compiler running:

    $> yum install gcc

    What we also need are the installation packages for DAViCal. Andrew McMillan, the man behind the project provides RPM packages on his website. We need to download AWL (http://debian.mcmillan.net.nz/packages/awl/)  and the DAViCal package (http://debian.mcmillan.net.nz/packages/davical/). You should choose the most recent RPM packages and obtain them using wget:

    $> wget http://debian.mcmillan.net.nz/packages/davical/davical-X.X.X.noarch.rpm

    and

    $> wget http://debian.mcmillan.net.nz/packages/awl/libawl-php-X.X.X.noarch.rpm

    (replace the X.X.X. with the version you chose)

    Tip: I created a download directory for the project to download all the required software and packages and store it there.

    Now lets install the two RPMs:

    $> rpm -ivh davical-X.X.X.noarch.rpm
    $> rpm -ivh libawl-php-X.X.X.noarch.rpm

    So far everything was easy. However in order to install DAViCal you need perl-YAML and the Perl Databasedriver for PostgreSQL. Unless you have those installed on your system you won’t be able to proceed. I have no idea why it was decided to use perl here, but that’s how it is. The problem is that the yum repository seems not to provide the correct versions the DAViCal installer expects, so any installation attempt will fail. It costed me about an hour to find out what to do and how to get the correct packages. Finding and installing a functioning version of YAML was easy. I got it here: http://packages.sw.be/perl-YAML/

    $> wget http://packages.sw.be/perl-YAML/perl-YAML-0.72-1.el5.rf.noarch.rpm
    $> rpm -ivh perl-YAML-0.72-1.el5.rf.noarch.rpm

    Getting the correct database driver was not so easy, though. The installer was not happy with none of the provided packages. I ended up getting the correct driver using the Perl MCPAN interface.

    $> perl -MCPAN -e 'install DBD::Pg'

    Now the DAViCal Installer should be happy with the database driver. However you still cannot start the installation because of a lousy postgresql error which will be something like  FATAL: Ident authentication failed for user <username> if you do so.

    This is because of a misconfiguration of the PostgreSQL client authentication config file (usually found in /var/lib/pgsql/data/pg_hba.conf). Use the editor of your choice to do that. For the duration of the installation you should change the config so that it accepts any connection from localhost by adding these lines to the config before all other rules:

    TYPE    DATABASE USER   CIDR-ADDRESS   METHOD
    local   all      all                   trust
    host    all      all    127.0.0.1/32   trust

    This is probalby a bad hack, but it worked for me. What we need to do now is to restart the database:

    $> service postgresql restart

    Next thing is to start the DAViCal install script:

    $> cd /usr/share/davical/dba$> su postgres -c ./create-database.sh

    If you followed all instructions precisely you should be awarded with a response that setting up DAViCal was successful:

    CREATE DATABASE
    Supported locales updated.
    CalDAV functions updated.
    RRULE functions updated.
    Database permissions updated.
    NOTE
    ====
    *  You will need to edit the PostgreSQL
       pg_hba.conf to allow the
       'davical_dba' database user access to the 'davical' database.
    *  You will need to edit the PostgreSQL pg_hba.conf to allow the
       'davical_app' database user access to the 'davical' database.
    *  The password for the 'admin' user has been set to 'A8cD3f9H'"
    
    Thanks for trying DAViCal!
    Check in /usr/share/doc/davical/examples/ forsome configuration examples.
    For help, visit #davical on irc.oftc.net.

    Tip: if anything went wrong during the installation process you will probably have to uninstall the davical database first. You do this with the command su postgres drobdb davical

    You should save the randomly generated password by all means as you will need it later on to configure your DAViCal server. Congratulations, you are half through ;) .

    We should now change the database permissions by changing the pg_hba.conf again. Best you change the rules you just created:

    TYPE    DATABASE USER   CIDR-ADDRESS   METHOD
    local   davical  davical_app           trust
    host    davical  davical_dba           trust

    After making the changes and saving the file, just restart the PostgreSQL server:

    $> service postgresql restart

    Now  we gonna setup Apache. I’m assuming that you want to set up DAViCal in a virtual host. Edit the httpd.conf in /etc/httpd/conf and add the virtual host:

    NameVirtualHost *:80
    
    <VirtualHost *:80>
        ServerName <your.domain.name>
        DocumentRoot /usr/share/davical/htdocs
        DirectoryIndex index.php index.html
        Alias /images/ /usr/share/davical/htdocs/images
        AcceptPathInfo On
        php_value include_path /usr/share/awl/inc
        php_value magic_quotes_gpc 0
        php_value register_globals 0
        php_value error_reporting "E_ALL & ~E_NOTICE"
        php_value default_charset "utf-8"
    </VirtualHost>

    Change <your.domain.name> with the appropriate domain name you want to use for your DAViCal server. You might have noticed that I used the installation directory of DAViCal as DocumentRoot. This is proposed on the DAViCal-Wiki and it works like a breeze.

    Now restart the the apache server:

    $> service httpd restart

    What you need to do now is to tell DAViCal where to find the database and other needed configuration parameters. DAViCal expects a config-file that is called using the following scheme: <domain-name>-conf.php. So if your domain serving DAViCal is ical.example.com then the file should be named ical.example.com-config.php. Its a simple PHP file, providing the configuration parameters for  the DAViCal server. There are numerous configuration options and you can look them up in the DAViCal-Wiki, but you need at least the database configuration parameters. An admin email address and the domain_name would be nice though:

    <?
      $c->domain_name = "ical.example.com";
      $c->admin_email = "admin.example.com";
      $c->pg_connect[] = "dbname=davical port=5432 user=davical_app";
    ?>

    (Change the parameters accordingly)

    Save the configuration file in /etc/davical/<domain-name>-conf.php.

    If you followed the instructions precisely, your DAViCal server should be up and running. You can start configuring it by opening the servers address in a browser and log in with the admin user and the password that was created by the setup script. Further configuration information could be found in the DAViCal wiki and on Sourceforge — there are some nice configuration instructions for Apples iCal and the iPhone.

     

    1 responses to “HOWTO: setting up DAViCal on CentOS 5.5” RSS icon


    1 Trackbacks / Pingbacks

    Leave a reply