Linux: Request Tracker 4 Installation

Request Tracker (RT) can be a tricky piece of software to install. It is written in perl and has many dependencies. Personally, I don’t really see the point in using it when there are fantastic (virtually painless) alternatives out there such as osTicket. RT also might not meet your requirements if you are a large enterprise having to adhere to ITIL practices. However, RT does have some advantages and is still used by quite a few major organisations. It is fairly robust and will do the job of helpdesk ticketing system nicely. This post will run through the installation from start to finish on RHEL/CentOS 6.

Login.

Before we go onto install RT, we need to install a massive amount of dependencies. Lets grab what we can using YUM:

wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
sudo rpm -Uhv remi-release-6*.rpm epel-release-6*.rpm
yum install -y mysql mysql-server mysql-devel graphviz mod_perl-devel mod_auth_mysql mod_perl mod_authz_ldap gd gd-devel gd-progs gcc mod_fcgid perl fetchmail procmail
yum install -y perl*
yum install -y cpan

NOTE: (As an aside to this, I have created puppet modules to install these dependencies, I may attach these in a later post. It doesn’t however go into building with CPAN)

Once all that is done.. we can configure Mysql in prep:
Edit /etc/my.cnf and add the following line:

max_allowed_packet=50M

This will allow users to attach larger files to tickets via email.
Then run the following commands to ensure everything will start:

chkconfig httpd on
chkconfig mysqld on
service mysqld start

We don’t want to start apache just yet.

We now need to harden our MySQL installation and set a password. Run:

/usr/bin/mysql_secure_installation

Take a note of the user and passwords you set as you need them later!

Apache:
Before we forget, we must add an apache vhost for RT. Create a file in /etc/httpd/conf.d/yoursite.conf where yoursite will be the CNAME of your rt install.
Copy in the following code: (Apologies for the formatting, this wordpress plugin doesn’t seem to like apache code)


AddDefaultCharset UTF-8
Alias /rt/NoAuth/images /opt/rt/share/html/NoAuth/images/
ScriptAlias /rt /opt/rt/sbin/rt-server.fcgi/
ServerName rt.yoursite.com
ServerAlias rt
DocumentRoot "/opt/rt/share/html"

 Order allow,deny
 Allow from all
 SetHandler modperl
 PerlResponseHandler Plack::Handler::Apache2
 PerlSetVar psgi_app /opt/rt/sbin/rt-server

use Plack::Handler::Apache2;
 Plack::Handler::Apache2->preload("/opt/rt/sbin/rt-server");

RT installation:

Now the fun begins.

RT has lots of different perl dependencies. Since CentOS and RHEL don’t keep all of these perl modules packaged, we need to configure CPAN to pull them down and install them.
Run the following commands:

perl -MCPAN -e shell

Then:

cpan[1]> o conf prerequisites_policy follow
cpan[1]> o conf commit
cpan[1]> install Bundle::CPAN

At this stage CPAN should start pulling down and building a load of perl modules. – If you get any failures, run it again. A second pass usually works. (At least it did for me)
When that finishes, from the CPAN shell, run:

cpan[1]> reload cpan
cpan[1]> reload index

Now we can download RT from here: http://bestpractical.com/rt/download_file.html
Once we have the latest version, copy it to /tmp.

Untar it & set ownership:

tar zxvf rt-4.2.1.tar.gz
chown -R root:root rt-4.2.1

Lets build it! (Note: The below configure parameters will install RT to /opt/rt. You can change this if you wish. See the README for more details on parameters)

cd rt-4.2.1
./configure --with-db-type=mysql --with-db-host=localhost --with-web-user=apache --with-web-group=apache --with-rt-group=rt --prefix=/opt/rt --enable-graphviz --enable-gd --enable-gpg --with-web-group=apache --with-rt-group=rt

Those dependencies I mentioned earlier? Well we are not done yet. We must ensure all PERL dependencies are present for RT. Run the following command. This will take some time.

make fixdeps

If there any issues when installing some dependencies perform:

cpan
cpan[1]>force install "dependency name"

When all that is done, you can check dependencies are present and working by running:

make testdeps

Once deps are resolved we can get RT built.

make install

If you have gotten this far, well done! We now want to update RT’s configuration.

Edit /oprt/rt/etc/RT_SiteConfig.pm. Add the following fields (here we are assuming “rt.yoursite.com” is the domain name)

Set($WebDomain, 'rt');
Set($rtname, 'rt.yoursite.com');
Set(@ReferrerWhitelist, qw(rt:80 rt.yoursite.com:80));
Set($Organization, "yoursite.com");
Set($CorrespondAddress, '@yoursite.com');
Set($CommentAddress, '@yoursite.com');
Set($Timezone, "Europe/London");
Set($OwnerEmail, '@yoursite.com');
Set($SMTPFrom, "@yoursite.com");
Set($ParseNewMessageForTicketCcs, 1);
Set($RTAddressRegexp, "\@yoursite.com");
Set($SearchResultsRefreshInterval, 30);
Set($HomePageRefreshInterval, 30);
Set($LogToSyslog, 'info');

Insert the relevant information.

Final Steps:

usermod -a -G rt apache
service httpd restart (or start)
make initialize-database

The last step is an interactive script that configures MySQL for RT. You will need the database password you set earlier for this.

Congratulations, RT should now be installed and working. Try logging in with these credentials:

User: root
password: password (change this immediately!)

The fun isn’t yet over however. You need to give RT the ability to process email and generate support tickets. Read on:

Configuring Fetchmail & Procmail

The packages for fetchmail and procmail should already be installed.

Create the file /opt/rt/.fetchmailrc and populate it with the following code (we are using IMAP here, I won’t go in to the specifics but if your configuration differs, please refer to the procmail user manual)

poll mailserver.yoursite.com protocol imap port 993 username "" password "" mda "/usr/bin/procmail -f %F" no keep ssl

Add the exchange mailbox username and password that you obtained for RT use. Save this file and set the following permissions:

chown rt:rt /opt/rt/.fetchmailrc
chmod 700 /opt/rt/.fetchmailrc

Now you need to create some procmail rules for RT. Now, I won’t go into this as procmail is a whole different topic alone. But you want to make sure there are filters in place to aviod ticket duplication and to prevent unauthorised users mailing in and creating tickets. This file needs to be saved as /etc/procmailrc.

Once you have created your rules you need to ensure the RT mailgate is called after the rules have been processed. At the bottom of .fetchmailrc, you need to add the command to call the RT Mailgate:

/opt/rt/bin/rt-mailgate --queue general --action correspond --url http://rt.yoursite.com

The procmailrc file also needs to be locked down. Set the following permissions:

chown root:root /etc/procmailrc
chmod 644 /etc/procmailrc

Now, to get fetchmail to start fetching, you must add a crojob to do so for the RT user (not root):

Run the following commands:

su - rt
crontab -e

Add this line:

*/1 * * * * /usr/bin/fetchmail -f /opt/rt/.fetchmailrc > /dev/null 2>&1

Or add the last line of that to /etc/crontab, specifying the RT user (not root!)
Fetchmail should now be fetching mail, filtering with procmail, then passing to the RT mailgate. You can test it by emailing your RT email address. At this point, a ticket will not be generated as you have to apply the correct permissions within RT for the general queue. BUT, if RT responds to your email complaining it can’t open a ticket, then you know that fetchmail is working!

Follow RT’s documentation to fully configure it to your needs. It is not a particularly intuitive interface but once it is working it can be great. Enjoy.

Leave a comment