Kalendus Manual - Installation

Perl, DBI, DBD, and Time-modules

Kalendus is written in Perl and uses several modules that may need to be installed. The DBI (database interface) and Msql-Mysql DBD (database driver) modules communicate with the MySQL database. These can be obtained from CPAN and installed according to the directions. These may already be installed, depending on your setup. The Time-modules set is used for all date calculations. These are all available from any CPAN mirror http://www.cpan.org/

These Perl modules are installed by downloading the latest .tar.gz file, extracting it, and running make. You normally need root/admin access to install them. If you do not have root/admin access, it is possible to install into a temporary directory using the PREFIX option and copy files to the Kalendus cgi-bin directory. For example, the latest version of Time-modules as of this writing is 100. After downloading the file, extract and install it:

tar -zxvf Time-modules-100.010301.tar.gz
cd Time-modules-100.010301
perl Makefile.PL
(or use 'perl Makefile.PL PREFIX=/tmp/foo')
make
make test
make install

MySQL

Kalendus uses MySQL as the backend database. I will not go into the installation of MySQL; see http://www.mysql.com/ for the downloads and documentation. MySQL was chosen because it is a freely available database, it is used by our web hosting organization (Gospelcom), and it is fairly efficient. The scripts could probably be modified to work with other SQL databases without too much difficulty. I will assume you have MySQL setup.

To set the MySQL server hostname, username, password, and database for Kalendus to use, edit the cgi-bin/config.pm file. It should be self explanitory. The Kalendus user needs select, insert, delete, and update priveleges. To give these priveleges (for MySQL 3.22.11 and beyond), use the mysql client to enter:

GRANT select, insert, delete, update
  ON calendar.*
  TO calendar@localhost
  IDENTIFIED BY 'password'

If you do not yet have a database in MySQL for Kalendus to use, create one using the mysql client:

CREATE DATABASE calendar

To create the necesary tables, use the SQL definitions in the tables.sql file. On UNIX, this can simply be redirected into the MySQL command line client. The username used to create the tables needs create privileges, and may be different than the username used by the Kalendus scripts.

mysql -h [mysql_server_host] -u [username] -p [database] < tables.sql

Apache

You may use any web server that allows execution of CGI scripts. However, I am familiar with Apache and will describe how to use it.

Kalendus has three directories: cgi-bin, which contains the CGI Perl scripts; images, which contains pre-done graphics for calendars and months; and doc, which contains the documentation. Install the cgi-bin directory where you want the scripts to be, and enable CGI execution in that directory. The Kalendus cgi-bin directory does not have to be named cgi-bin; at IVP it is named calendar. If you install the Kalendus cgi-bin directory in an existing CGI directory, it is often ScriptAliased and you do not need to change Apache's configuration. At IVP, Kalendus is installed outside our normal CGI directory, so I enable ExecCGI and add the CGI handler for Perl scripts. For instance, in the Apache config file 'access.conf':

<Directory /home/httpd/html/calendar/cgi-bin>
  Options ExecCGI
</Directory>

Apache also needs to know what files to run as CGI scripts, rather than downloading. If the cgi-bin directory is ScriptAliased, that should suffice. Otherwise, add a handler for Perl scripts, which end in .pl, to the Apache config file 'srm.conf':

AddHandler cgi-script .pl

If you want password authentication, either the whole Kalendus cgi-bin directory can be password protected, so no unauthorized users can see your calendars, or just the cgi-bin/auth/ directory can be password authentication, so no unauthorized users can add or change events on your calendars. See the excellent tutorials on the Apache site for how to do this. An example configuration might be:

<Directory /home/httpd/html/calendar/cgi-bin>
  Options ExecCGI

  #
  # Only allow people in the 'calendar' group
  #
  AuthType      Basic
  AuthName      "Calendar"
  AuthUserFile  /home/httpd/passwd
  AuthGroupFile /home/httpd/group
  require       group calendar
</Directory>

Install the images/ and doc/ directories where you want them. This location should be in your normal webspace, not in the CGI directory.

Reload the Apache server (e.g. using 'apachectl restart' or '/etc/init.d/httpd reload').

If everything is setup correctly, you can view the calendar using the month.pl script, e.g.: http://yourhost.domain.com/calendar/cgi-bin/month.pl. If something doesn't work, see the troubleshooting section below.

Calendar Configuration

There are a number of items you may wish to configure in the Kalendus scripts. All configurable values can be set using the cgi-bin/auth/config.pl script. Use the same username for this script as for all the others; it asks for the username/password instead of getting it from the config.pm file as a security measure.

Once you have finished configuring Kalendus to your liking, you may want to change the HTML pages to fit in with your site design. See the HTML templates documentation.

Troubleshooting

A few common errors and possible causes that might occur when trying to access the Kalendus scripts online.

In debugging, it is very helpful to try running the month.pl Perl script from the command line. Just type control-D after running it to get it to run. Also check the Apache access and error logs, typically found in /var/log/httpd/access_log and error_log.

Not Found
Apache couldn't find the Kalendus scripts. Check that the URL is typed correctly and that Apache maps the URL to where you installed Kalendus. For example, I have Apache configured to map the URL http://localhost/calendar/ to the directory /home/httpd/html/calendar/.
Forbidden
Apache is not configured to allow execution of CGI scripts where Kalendus is installed. Check that you added the directory with the ExecCGI option to the Apache access.conf file, and reloaded Apache. Alternatively, the Perl scripts do not have execute permissions set. Make sure their permissions allow them to be executed by the Apache server (at least chmod 555 or chmod a+rx).
The web browser tries to download the Perl script
Apache doesn't know to execute month.pl as a CGI script. Check that you added a handler for Perl scripts to the Apache srm.conf file, and reloaded Apache.
Internal Server Error
Either a bug in the Perl script, or Apache can't find the Perl executable to run the script. The first line of each script is #!/usr/bin/perl which must be the Perl executable on your system. Change the path in the scripts if necesary. Perl may also not be able to find the modules it needs (see installing Perl above). Try running the month.pl script from the command line or look at the Apache error logs, to see if you can glean any information that way.
Can't locate DBI.pm
Can't locate DBD/mysql.pm
Can't locate Time/DaysInMonth.pm
Perl can't locate one of the modules it needs. Make sure DBI, DBD, and Time-modules are installed in one of the directories listed.
Can't locate FT.pm
Can't locate calendar.pm
Can't locate config.pm
Perl can't locate one of the modules supplied with Kalendus. Make sure config.pm and calendar.pm are in the cgi-bin/ directory, and FT.pm is in the cgi-bin/FT/ directory.
An internal error occured: could not connect to MySQL server through socket '/var/lib/mysql/mysql.sock' (111)
Usually a permissions problem. Check that the user the web server runs as has permission to read/write the given file, and can read all its parent directories.
An internal error occured: could not connect to server, Can't connect to MySQL server on 'localhost' (111)
The MySQL database is not running on the indicated server. Start MySQL on a host and set the host in the config.pm script.
An internal error occured: could not connect to server, Unknown database 'calendar'
The calendar database and tables need to be created in MySQL, or the database name needs to be set in the config.pm script. See the tables.sql file, above.
An internal error occured: could not connect to server, Access denied for user: 'calendar@localhost' (Using password: YES)
MySQL is not accepting the username/password to connect to the calendar database. Set the username and password in the config.pm script. Make sure you ran the GRANT command listed above. Older versions of MySQL don't support the GRANT command and need to be reloaded after changing priveleges.
Died at calendar.pm line 101.
Probably you forgot to create the tables in the MySQL database. Run month.pl from the command line to get a more descriptive error message.
FT FATAL ERROR: Couldn't open file
The HTML template files could not be located. Make sure month.html, event.html, select.html are in the same directory as month.pl; edit.html, confirm.html, and select.html (slightly different copy) are in the same directory as edit.pl and confirm.pl. Make sure their permissions allow them to be read by the Apache server (at least chmod 444 or chmod a+r).
Authorization Required
Apache could not authenticate you as a valid user. You may have setup the calendar/auth/ with Apache HTTP authentication, to prevent unauthorized people from adding or modifying events on the calendar.
Broken links to graphics
Some links to graphics are hard coded in HTML templates. Edit the HTML templates to update the URLs. The calendar and month images are configurable using the cgi-bin/auth/config.pl script. Make sure their file permissions allow them to be read by the Apache server (at least chmod 444 or chmod a+r).

Mark Gates
Last modified: $Date: 2001/04/12 23:10:07 $