Westhost Tips and Tricks

This is a series of papers on working with Westhost servers. It only applies to you if you are a Westhost customer. Any additions, corrections, feedback: email 'wh @ gnomedia.com'.

I'm occasionally available for contract or consultation work, contact me via the gnome above if you have a request.

Read the introduction first, it contains important information and warnings!

Perl: modifying the installation

Westhost’s Perl installation.

Westhost has Perl installed in the usual places. Unfortunately some (but not all) of the Perl modules are owned by root and cannot be overwritten. I’ll look at ways of working around this problem. Towards the end of the article we will look into upgrading the SpamAssassin installation using the techniques mentioned.

Installing Perl Modules on Westhost.

Perl makes a lot of use of library modules, which can be installed and updated separately from the Perl program itself. These modules are normally installed using CPAN (itself a Perl module) which is used to automate the process of connecting to CPAN server and downloading, make’ing and installing the modules. On most servers, this is done as the root user, because a base Perl installation is normally owned by root. However on Westhost, we don’t have root privileges so we need to take some extra steps to install the modules elsewhere. What follows is a method of doing that. CPAN stands for the Comprehensive Perl Archive Network and more information on it can be found at http://www.cpan.org/

Before starting you need to make sure that you have the GCC Compiler Collection installed, this is needed and without it Perl will still run but building of the modules will probably (but not certainly) fail. And remember, you are messing with the server system, if you’re not comfortable with doing this, don’t!

Because we don’t have root privileges to install or update the Perl modules, we need to install the modules elsewhere, in a directory that we have access to. In addition to installing the modules, we also need to tell Perl where the extra libraries are installed so that Perl can find them when running. We are going to create a directory ‘/perl5lib’ and use that for the installations. You can call the directory what you want and install it wherever you like as long as you have write permission for it. In the following I will assume it is ‘/perl5lib’.

Create the directory /perl5lib. Then start up the CPAN modules, this is done by typing:
$ perl -MCPAN -e shell
or, alternatively:
$ cpan

The cpan shell will then realize that this is the first time it has been called and ask if you want to do a manual configuration. You do, so answer yes. If you have already run cpan before and configured it, see below for modifying the configuration. All the questions have default answers and you can just hit enter to accept the default, until you reach a question like: “Parameters for ‘perl Makefile.PL’ command?”
Here you want to enter the following:
PREFIX=/perl5lib LIB=/perl5lib/lib INSTALLMAN1DIR=/perl5lib/man1 INSTALLMAN3DIR=/perl5lib/man3

Accept the defaults for the next few questions until you are asked for your favorite mirrors. You want to choose mirrors in North America/United States and then select some mirrors.

Once that is done, continue with the defaults to any questions until you are back at the cpan prompt and then type quit.

If you have run cpan before and configured it and need to change the configuration, then do this (note the quotes):

$ cpan
cpan>o conf
cpan>o conf makepl_arg "PREFIX=/perl5lib LIB=/perl5lib/lib INSTALLMAN1DIR=/perl5lib/man1 INSTALLMAN3DIR=/perl5lib/man3"
cpan> quit

So, now we have told CPAN about our new directory, we need to tell the system about it as well. For this you need to enter the following line in your .bashrc file:
export PERL5LIB=/perl5lib/lib

Save the file, and log off the SSH session. Then log back in again.

Now we are ready to try installing a module. A good test of the system is to install an update for the CPAN modules itself. Start cpan:
$ cpan
cpan> install Bundle::CPAN

There will then be a flurry of activity, possibly a few warnings until you get a question about ‘unsatisfied dependencies’. Answer ‘yes’ to have them installed as well (the dependencies might vary, but on my system CPAN also installed Digest::MD5 and File::Spec). There will be a lot more text scrolling by until you finally get a success message and you are returned to the prompt. Next, reload cpan with:
cpan>reload cpan
and, assuming that was successful, you should be able to install the modules that you need.

Upgrading SpamAssassin

Probably the most requested upgrade is for SpamAssassin. As I write this (March 2004) the current version of SpamAssassin on Westhost is 2.53, about a year old. The latest version on SpamAssassin.org’s web site is 2.63, a substantial improvement. So, here’s how I upgrade SpamAssassin…

I used to list out three ways of upgrading SpamAssassin, probably sowing the seeds of more confusion than I realised, so now I’ve simplified it to the way I’ve settled on using, I’ll mention the other methods at the end. Make sure you’ve checked the previous section above for general information on installing Perl modules.
[Note: You will need the GCC compiler kit installed for this first method. If you don’t then check out the third method.]

  • Make a backup of your /etc/mail/spamassassin/local.cf if you’ve changed it.
  • Download the latest spamassassin source from spamassassin.org. (You can use lynx to do this while logged in to the server).
  • Unpack the downloaded gzipped tar file.
    $ tar xzf spamassassin-2.63.tar.gz
  • Change to the new unpacked directory.
    $ cd Mail-Spamassassin-2.63
  • Run the following commands:
    perl Makefile.PL PREFIX=/sa SYSCONFDIR=/etc
    make
    make install
    
    (this will install spamassassin in /sa/bin, /sa/lib and point them towards /etc/mail/spamassassin/local.cf.) [If you get a warning about SYSCONFDIR being unknown, then you need to upgrade ExtUtils::MakeMaker, see the CPAN section above]
  • Run the command:
    $ /sa/bin/spamassassin –lint -D
  • Check the output and see if it makes some kind of sense, no errors etc. Then go and have a cup of coffee, that’s the hard part done.
  • Now we will use CPAN to install the Net::DNS::Resolver module for RTBL lookups:
    $ cpan
    > o conf makeplarg ”
    > install Net::DNS::Resolver
    ….. (bunch of output…)
    > quit
    
    The ‘o conf makeplarg’ line is to persuade CPAN to install the module in the default location.
  • Assuming there were no errors in the previous stage, then you should be able to do:
    $ /sa/bin/spamassassin –lint -D
    and this time there will be a line similar to:
    debug: is Net::DNS::Resolver available? Yes
    
    which indicates that SpamAssassin is now using a DNS lookup to check the IP addresses of the received email against a RealTime Blacklist.
  • When you are ready to change over to using the new spamassassin, do this (in the root directory):
    $ mv spamassassin spamassassin-2.53
    $ ln -s /sa/bin/spamassassin spamassassin
    
    which will create link to the new spamassassin and everything will work as normal. *That’s it!

I mentioned that there are other ways to install SpamAssassin, here is a brief discussion of them:

  • Upgrading the modules using the CPAN network.
    This is probably the best way to perform a SpamAssassin upgrade as it takes place within the CPAN framework. Many people have had trouble using this installation route as at one stage the installation throws an error (to do with unlinking a module that has been installed as root) and the installation stops there. To use this upgrade route, you will need the GNU Compiler suite installed on your site (although it can be removed afterwards). Then run cpan and install SpamAssassin and Net::DNS::Resolver (see above). Note that we need the installation path set to /perl5lib for SpamAssassin and then reset the installation path to install Net::DNS in the normal library space.

    $ cpan
    > install Mail::SpamAssassin
    ..... (bunch of output...)
    > o conf makepl_arg ''
    > install Net::DNS
    ..... (bunch of output...)
    > quit
    

  • Upgrading using a prebuilt package from another Westhost site.
    Once you’ve upgraded the SpamAssassin package using the first method above, its a simple matter to copy it over to another site and setup the link as shown. And, in the spirit of helpfullness that we value so much here at gnomedia, we’ve supplied a package that you can upload and install.
    Once you’ve uploaded the tarball to your site, you need to do this (in the root directory):

    $ tar xzf sa-2.63.tgz
    $ mv spamassassin spamassassin-2.53
    $ ln -s /sa/bin/spamassassin spamassassin
    $ /spamassassin --lint -D < /dev/null
    
    [Note: On some older installations, the /spamassassin binary is owned by root and can’t be renamed or deleted. In this situation you will need to edit /etc/procmailrc and point it towards /sa/bin/spamassassin directly.]
    And that should be all thats needed. The main difference between this installation and the one I recommend above is that with this package the site configuration file is in the /saconf/mail/spamassassin directory and not in the /etc/mail/spamassassin directory.

Note that neither of the last two methods will install Net::DNS (for DNS lookups). Follow the instructions in the recommended install process for that.