Chapter 2. Installation

Before you can make use of most of the wonderful advice and tricks in this book, you need a live RT instance running. If you already have an installed and running RT instance, skip to Chapter 3. In many ways, the initial installation of RT is the hardest part. RT is a complex Perl application with many dependencies—once all of those dependencies are in place, RT installs easily. Most of the time installing RT is spent installing those modules.

RT was designed to run on UNIX and UNIX-like systems. This means Linux, Solaris, FreeBSD, IRIX, HP/UX, Mac OS X, and similar systems. If your operating system of choice has pre-built packages for RT, that is the easiest way to install it. These third party packages are contributed and don’t come from the RT developers. As of this writing, packages are available for Debian, FreeBSD, RedHat, and Mandrake Linux. There are some downsides to these packages: they may put files in unexpected locations to conform to packaging requirements, and they also may be out of date.

RT also runs on Windows. It is experimental and unsupported, so this chapter won’t cover it, but it generally works. All of the component pieces (Perl, Apache, and MySQL) are available natively. The easiest way to get it running is to use Autrijus Tang’s pre-packaged version of RT for Windows, which includes all the component pieces in one convenient installer. Download it from http://wiki.bestpractical.com/?WindowsOSInstallGuide.

Before you begin setting up RT, you need to satisfy a few requirements. RT is complex, and the requirements are fairly strict, as Perl applications go.

Ultimately, RT is all about its database . You have several options here:

RT runs equally well on MySQL and PostgreSQL. Oracle support is relatively new, but it should be as stable as the MySQL and PostgreSQL. An option for development is SQLite, a lightweight single-file database engine. We don’t recommend you run it in a production environment, because it doesn’t support high levels of concurrency well. Check the README file that comes with RT to see if the latest version supports any other databases.[4] You should choose which database to use based on what’s familiar to you and what resources you have available.

If you don’t have a preferred database, we suggest you choose MySQL. It is the easiest supported database to set up and maintain.

It may be possible to make RT install on earlier versions of MySQL or PostgreSQL, but as with earlier versions of Perl, you may run into trouble. In general, we recommend using the latest stable release version of whichever database you choose. At the time of writing, that version is MySQL 4.1.10 and PostgreSQL 8.0.1.

For production uses, you want a scalable web server (instead of the standalone_httpd that comes with RT). Any of the following will do:

As with choice of database, choice of web server often depends on what you already have installed. If you’re building a stand-alone RT system, the most stable configuration is the latest Apache 1.3 series release with the latest compatible mod_perl 1.x release.

At the time of this writing, mod_perl 2.0 has just been released. Some of the libraries that RT depends on haven’t been put through their paces with it. During the mod_perl 2 beta cycle, most of the kinks have been worked out, but there could still be some gremlins hiding in the corners. (Make sure you build your Apache 2.0 with the prefork MPM to avoid odd threading issues.)

For more information on choosing between different Apache versions, you might want to look at Apache: The Definitive Guide, 3rd Edition (O’Reilly).

Most everyone runs RT on an Apache or Apache-derived web server, but RT’s FastCGI server is known to play well with other servers. If you use something else, like SunOne/Netscape/iPlanet or WebStar and have a FastCGI plugin for it, it should work.

RT makes heavy use of freely available Perl libraries available on the CPAN. To make your installation process somewhat smoother, Best Practical has created a (mostly) automated procedure using the CPAN.pm module to download and install libraries from CPAN. See Step 6: Check for RT’s Perl Dependencies later in this chapter. Depending on your system configuration, there are still a couple of difficult modules that must be installed manually—mostly ones that require external libraries to be present, like your database’s client libraries or the Apache libraries.

A list of required modules and versions can be found in Appendix D.

Get yourself a comfortable chair, a nice drink, some free hard disk space, and sit down for an hour or so of module building and configuration to install RT.

You can find information about the latest RT releases from the official RT download page at http://www.bestpractical.com/rt/download.html. In addition to the locations for packaged releases, this page also contains instructions on how to download the latest development copy of RT.

The latest stable release of RT is always available as http://download.bestpractical.com/pub/rt/release/rt.tar.gz, so you can grab that now, and place it in /tmp.

Now you need to tell RT how to install itself by running the configure program. It takes a number of different options. We’ll explain most of them here and in the following sections, but you can get a complete and current list with the —help option:

    # ./configure --help

These settings (see Table 2-1) control the file ownership that will be used on all of the installed files. You must make sure that all the users and groups exist before you try and configure RT. They are optional unless you wish to change the detected defaults.

By default, RT assumes the existence of several users and groups on your system and will autodetect the defaults mentioned in this table. The standard configuration is to have all RT files owned by a ‘rt’ group. The installation process will chown or chgrp any files and directories that need to be accessible by the webserver.

These defaults are probably fine for most people installing into a system-wide directory like /opt/rt3 or /usr/local/rt3. The reason for this complex set of permissions is because only certain users/groups should be able to write to (and read) certain files for security purposes.

On some systems, the web-user and web-group should be set to “nobody”, “apache” or “httpd.” Look at the User and Group lines in your httpd.conf for details.

If you are performing a non-root install, (i.e., into your home directory or entirely as a special rt user) then you can use --with-my-user-group to use only your current user and group. This will use the current value of the $USER or $LOGUSER environment variables and the first entry in the output of “groups”.

Some systems have multiple instances or versions of Perl installed, and you don’t always want to use the default one for RT. (This is especially true because RT requires a recent version of Perl to function properly.) Use the PERL environment variable to specify the location of the Perl binary you want RT to use. For example:

    $ env PERL=/usr/local/bin/perl ./configure
    checking for a BSD-compatible install... /usr/bin/install -c
    checking for perl... /usr/local/bin/perl
    checking for chosen layout... RT3
    checking if user www exists... not found
    checking if user www-data exists... not found
    checking if user apache exists... found
    checking if group www exists... not found
    checking if group www-data exists... not found
    checking if group apache exists... found
    checking if group rt3 exists... not found
    checking if group rt exists... found
    checking if group apache exists... found
    which: no apachectl in (/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin)
    configure: creating ./config.status
    config.status: creating sbin/rt-dump-database
    config.status: creating sbin/rt-setup-database
    config.status: creating sbin/rt-test-dependencies
    config.status: creating bin/mason_handler.fcgi
    config.status: creating bin/mason_handler.scgi
    config.status: creating bin/standalone_httpd
    config.status: creating bin/rt-crontool
    config.status: creating bin/rt-mailgate
    config.status: creating bin/rt
    config.status: creating Makefile
    config.status: creating etc/RT_Config.pm
    config.status: creating lib/RT.pm
    config.status: creating bin/mason_handler.svc
    config.status: creating bin/webmux.pl

This shows a default configuration of RT, using the Perl binary located at /usr/local/bin/perl and installing into the default location (/opt/rt3). Web scripts will be owned by the Apache user and in the Apache group. All other files will be in the rt group.

RT comes with a handy script called rt-test-dependencies that automatically queries your chosen version of Perl for all the modules that RT requires, and generates a report of what it finds. You can have RT run this script with the right options by issuing the following command:

    # make testdeps

The script will output a report similar to the following:

    /usr/local/bin/perl ./sbin/rt-test-dependencies --verbose --with-mysql
    perl:
            5.8.3...found
    users:
            rt group (apache)...found
            bin owner (root)...found
            libs owner (root)...found
            libs group (bin)...found
            web owner (apache)...found
            web group (apache)...found
    MASON dependencies:
            Params::Validate 0.02...found
            Cache::Cache ...found
            Exception::Class 1.14...found
            HTML::Mason 1.23...found
            MLDBM ...found
            Errno ...found
            FreezeThaw ...found
            Digest::MD5 2.27...found
            CGI::Cookie 1.20...found
            Storable 2.08...found
            Apache::Session 1.53...found
            XML::RSS ...found
            HTTP::Server::Simple 0.07...MISSING
                    HTTP::Server::Simple version 0.07 required—this is only version 0.04
    at (eval 41) line 2, <DATA> line 11.
            HTTP::Server::Simple::Mason 0.03...found
    MAILGATE dependencies:
            HTML::TreeBuilder ...found
            HTML::FormatText ...found
            Getopt::Long ...found
            LWP::UserAgent ...found
    CLI dependencies:
            Getopt::Long 2.24...found
    CORE dependencies:
            Digest::base ...found
            Digest::MD5 2.27...found
            DBI 1.37...found
            Test::Inline ...found
            Class::ReturnValue 0.40...found
            DBIx::SearchBuilder 1.21...found
            Text::Template ...found
            File::Spec 0.8...found
            HTML::Entities ...found
            HTML::Scrubber 0.08...found
            Net::Domain ...found
            Log::Dispatch 2.0...found
            Locale::Maketext 1.06...found
            Locale::Maketext::Lexicon 0.32...found
            Locale::Maketext::Fuzzy ...found
            MIME::Entity 5.108...found
            Mail::Mailer 1.57...found
            Net::SMTP ...found
            Text::Wrapper ...found
            Time::ParseDate ...found
            Time::HiRes ...found
            File::Temp ...found
            Term::ReadKey ...found
            Text::Autoformat ...found
            Text::Quoted 1.3...found
            Tree::Simple 1.04...found
            Scalar::Util ...found
            Module::Versions::Report ...found
            Cache::Simple::TimedExpiry ...found
            XML::Simple ...found
    DEV dependencies:
            Regexp::Common ...found
            Test::Inline ...found
            Apache::Test ...found
            HTML::Form ...found
            HTML::TokeParser ...found
            WWW::Mechanize ...found
            Test::WWW::Mechanize ...found
            Module::Refresh 0.03...found
    MYSQL dependencies:
            DBD::mysql 2.1018...found

If anything is missing, RT can use the CPAN.pm module to install it. If you haven’t previously configured CPAN.pm, you need to do that before running this script. Run perl -MCPAN -eshell and follow the instructions. Then, RT can attempt to automatically install the necessary modules; run make fixdeps:

    # make fixdeps

This step requires either a network connection—to contact a CPAN mirror—or a local CPAN mirror, so that the installer can download any missing modules.

Earlier, you had the chance to specify three potentially different users and three groups: the user and group to own the scripts that RT installs, the user and group to own the libraries that RT installs, and the user and group that will run the web server process. At this point, you should make sure that these users and groups exist, because if they don’t, the installation process will fail. How to do this depends on your system, but many systems provide the useradd and groupadd tools to automate the process. However you do it, create the users and groups now, if necessary.

RT will create the appropriate database, users, and initialize some tables when you run make initialize-database. (Do not run this more than once, unless you want to lose your data.)

    # make initialize-database
    Creating mysql database rt.
    Now populating database schema.
    Creating database schema.
    schema sucessfully inserted
    Now inserting database ACLs
    Now inserting RT core system objects
    Checking for existing system user...not found.  This appears to be a new installation.
    Creating system user...done.
    Now inserting RT data
    Creating Superuser  ACL...Creating groups...3.4.5.6.7.8.9.done.
    Creating users...10.12.done.
    Creating queues...1.2.done.
    Creating ACL...2.3.done.
    Creating ScripActions...1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.done.
    Creating ScripConditions...1.2.3.4.5.6.7.8.9.done.
    Creating templates...1.2.3.4.5.6.7.8.9.10.11.12.done.
    Creating scrips...1.2.3.4.5.6.7.8.9.10.11.12.13.done.

At this point, RT is installed. The next step is to configure it and then configure your web servers and mail servers to talk to it properly. If you already have a webserver with mod_perl or FastCGI set up, the hard work is over.

The primary configuration file for RT is etc/RT_SiteConfig.pm, which is based on etc/RT_Config.pm. You should never edit etc/RT_Config.pm. It contains default values and will get overwritten during upgrades. However, any changes you make in etc/RT_SiteConfig.pm will take precedence.

RT has many configuration options, but most sites only need a few to get up and running. For more advanced configuration options, see Chapter 7 and Appendix E.

The data in RT_SiteConfig.pm can be in any order. You should place things in logical groupings, so that you can easily find them. The definitive reference on the possible configuration options for any particular version of RT is RT_Config.pm.

Once you’ve finalized the configuration for your new RT instance, be sure to back up RT_SiteConfig.pm somewhere safe. Other than the database, this is the single most important file in your RT installation, and complex configurations can be difficult and time-consuming to recreate manually.

There are some options you must configure. They are site-specific information.

The $rtname option is a short, unique name for this particular RT instance. It appears in the subject line of emails, so the RT instance can determine that the ticket was intended for it. Do not choose a generic name like “support” or “tech” for your $rtname, because this has the potential to conflict with other RT instances. A short version of your company name or its acronym are good examples.

    Set($rtname, "examplecorp");

$Organization should be a unique identifier for this particular RT instance, similar to a domain-name. $Organization is used for generating message identifiers and linking between RT instances. It does not necessarily have to be a valid hostname.

    Set($Organization, "rt.example.com");

Once you chose a $rtname and $Organization, you will need to be very careful about changing them, because RT uses them internally to maintain data structures.

Setting the $Timezone isn’t required, but your users will be happier if you do. The value is system-specific. Look in your zoneinfo database directories (usually located in /usr/share/zoneinfo or /usr/share/lib/zoneinfo) for valid values.

    Set($Timezone, 'US/Pacific');

You will also need to set $WebPath and $WebBaseURL to match how you will configure your webserver. $WebBaseURL should not have a trailing slash. $WebBaseURL includes the schema, hostname, and port (if necessary) for your RT instance. $WebPath is the rest of the path. An RT instance at http://support.example.com/rt3 would use the following settings:

    Set($WebBaseURL, "http://support.example.com");
    Set($WebPath, "/rt3");

Or, an RT instance on its own virtualhost at http://rt.example.com/ might use the following:

    Set($WebBaseURL, "http://rt.example.com");
    Set($WebPath, "/");

Now that you have RT configured, it is time to configure your webserver. In the previous stage you set $WebBaseURL and $WebPath to where in “URLspace” you plan to have RT installed. Now we’ll tell Apache about those values. (If you are not using Apache, you will need to extrapolate from the FastCGI section below.)

An alternative to mod_perl is FastCGI. FastCGI is a protocol designed to allow a web server to run CGI scripts via a separate, persistent program. FastCGI defines how a web server interacts with this separate program in much the same way that the CGI spec defines how a web server and regular spawned programs interact. There are FastCGI implementations for many web servers—including Apache 1.3.x and Apache 2.x—that should work just fine with RT.

There are several cases where you might want to use FastCGI instead of mod_perl:

The official FastCGI homepage is at http://www.fastcgi.com/, and it provides a lot of good information about running and developing FastCGI applications, as well as download information.

Configuring FastCGI under Apache, you’ll need this chunk of configuration in your httpd.conf:

Under Apache, as a separate virtual host, the configuration looks like this:

    <VirtualHost *>
      ServerName rt.example.com
     
      FastCgiServer /opt/rt3/bin/mason_handler.fcgi
      AddHandler fastcgi-script fcgi
      Alias /NoAuth/images/ /opt/rt3/html/NoAuth/images/
      ScriptAlias / /opt/rt3/bin/mason_handler.fcgi/
    </VirtualHost>

If your RT will live at /rt3/, the configuration would look like this:

    FastCgiServer /opt/rt3/bin/mason_handler.fcgi
    AddHandler fastcgi-script fcgi
    Alias /rt3/NoAuth/images/ /opt/rt3/html/NoAuth/images/
    ScriptAlias /rt3 /opt/rt3/bin/mason_handler.fcgi/

By default, FastCGI will start only one process at a time. If your RT instance experiences high concurrent use, you will want to tell FastCGI to start more processes by using the -processes option to FastCgiServer.

    FastCgiServer /opt/rt3/bin/mason_handler.fcgi -processes 10

Depending on your configuration, you might not be able to, or want to, run RT on your main webserver. One solution to this problem is to use a proxy in front of it. Figure 2-1 shows a proxied RT server. Apache 2.x, beyond being a webserver, also can function as a high-performance proxy.

There are several reasons you might want to do this:

First, only one instance of a mod_perl 1.x application can run inside Apache at a time, because there is a shared Perl interpreter. Multiple instances of an application can conflict with unexpected and undesirable results. A proxy can be used to map multiple instances into one URLspace.

Apache 2.x and mod_perl 2.x doesn’t have this limitation. Perl interpreters can be bound to VirtualHosts or Locations with PerlOptions +Parent .

Second, Perl applications use a lot of RAM, and all Apache processes will end up allocating this RAM. If you also are serving static content, the memory usage will be high, thus limiting the number of Apache processes a machine can support and throughput..

Third, a proxy can allow your server to serve more requests. The back-end server won’t need to buffer for a slow network connection and can quickly return to serving requests. This means you will need fewer heavy mod_perl processes running.

Finally, RT is designed to be a secure application, but as with any piece of software there is always potential for a hole to be found. By using a proxy to a dedicated Apache server, RT can be isolated from other services on the system. A compromise of RT would not imply instant access to the rest of the web system.

Apache 2.x is a good candidate for this, as it’s a bit faster and a little more flexible than Apache 1.x.

In your front-end proxy webserver, use the following configuration, after making sure that mod_rewrite and mod-proxy loaded:

    <VirtualHost *>
        ServerName rt.example.com
        RewriteEngine On
        RewriteRule ^/(.*)$ http://localhost:8284/$1 [P,L]
    </VirtualHost>

Under Apache 2.x, mod_proxy offers a cleaner configuration:

    <VirtualHost *>
        ServerName rt.example.com
        ProxyPass / http://localhost:8284/
        ProxyPassReverse / http://localhost:8284/
    </VirtualHost>

Then, as shown in Figure 2-1, configure another Apache running RT on a high-numbered port, such as 8284 in this example. You can configure your firewall so it can only receive traffic from the proxy server.

This approach is explained in great detail in the mod_perl documentation, at http://perl.apache.org/docs/1.0/guide/strategy.html, and in the mod_perl Developer’s Cookbook, by Geoffrey Young, Paul Lindner, and Randy Kobes (Sams) and in Practical mod_perl by Stas Bekman and Eric Cholet (O’Reilly).

Configuring RT to send mail consists of a few steps. First of all, make sure that the server has a working MTA (Mail Transfer Agent).

Common MTAs include sendmail (http://www.sendmail.org/), postfix (http://www.postfix.org/), and qmail (http://cr.yp.to/qmail.html). Most Unix-based operating systems ship with at least one of these available by default (Linux distributions have almost all of them available, in fact). Installing and configuring the MTA is beyond the scope of this book, but the vendors’ web sites all provide detailed installation and configuration instructions.

Once you have the MTA installed and set up to send mail, you need to tell RT to use it. Look in the RT_Config.pm file, and copy the following lines to RT_SiteConfig.pm:

    Set($SendmailPath , "/usr/sbin/sendmail");
    Set($SendmailArguments , "-oi -t");

Since it’s the traditional location for sendmail, /usr/sbin/sendmail will usually work. Most other MTAs respect this tradition through compatibility wrappers. If /usr/sbin/sendmail does not exist, try /usr/lib/sendmail.

Incoming mail destined for RT is processed through RT’s mailgate, conveniently called rt-mailgate. When it is invoked, this script parses the incoming message, and transfers it to your main RT server for processing. The mailgate does not have to run on the same machine as your main RT server, as long as it can communicate with it via http or https.

MTAs have the ability to pass mail destined for particular addresses to a program instead of to a mailbox, and RT utilizes this. Unfortunately, this feature is configured differently for different MTAs. Most of them support Sendmail’s traditional aliases format, so that’s the format we’ll be using for the examples in the following sections. A notable exception is qmail, which will be covered separately.

Unlike Sendmail and Postfix, qmail uses specially-named files in a user’s home directory to determine the handler for a message. Since you have already created a user account for RT, you can set that user up to process all RT-related mail. When qmail’s delivery agent tries to figure out what to do with an incoming message for a user, it first looks to see if there is an extension to the username. By default, this extension is separated from the username by a dash (-), so you could have , where rt is the username and foo is the extension. If there is an extension, then qmail will look in the rt user’s ~/.qmail-foo file for delivery instructions. Otherwise, it looks in the rt user’s ~/.qmail file.

To set up mail delivery into RT, you can create a series of .qmail files, two for each queue (for responses and comments). For example, the General queue would be handled by these files:

    # cat ~rt/.qmail-general
 |/opt/rt3/bin/rt-mailgate --queue General --action correspond --url
http://rt.example.com/
     
    # cat ~rt/.qmail-general-comment
 |/opt/rt3/bin/rt-mailgate --queue General --action comment --url http://rt.example.com/

With these files in place, mail sent to will become correspondence in the General queue, and mail sent to will become comments in the General queue.

You also can create a catch-all .qmail-default file:

    # cat ~rt/.qmail-default
 |/opt/rt3/bin/rt-mailgate --queue $DEFAULT --action correspond --url http://rt.example.com/

Anything sent to rt-queuename will be delivered as correspondence to the queuename queue.

Note the rt- at the beginning of each address; that is because the mail is actually being sent to the rt user and handled using qmail’s convenient features. Setting up qmail so that these messages are handled globally, and not by a particular user, is a little different. Rather than a global /etc/aliases file, like the other MTAs use, qmail has a general alias user that handles all system-wide aliases. To make this user handle mail for RT, simply create the files ~alias/.qmail-general and ~alias/.qmail-general-comment with the same content as before. This allows the RT addresses to be and . Under RT2, the mail handling script had to be setgid to the rt group, so the user restriction was important, but under RT3, this is no longer the case.

Not everyone’s installation goes perfectly the first time. There are some common problems that may occur.

Some places to go for help are the rt-users mailing list on http://lists.bestpractical.com, Chapter 8, or the RT Wiki at http://wiki.bestpractical.com.

At this point you should have a working RT instance. Restart your Apache, and test it out by pointing your web browser at whatever URL you’ve specified.

The default administrator user for RT is called root and the password is password. After you log in for the first time, you will want to change this by clicking on “Preferences” in the upper right hand corner.



[4] As of this writing, Informix and Sybase support is being developed.

[5] This is a very simple way to implement mailing lists.