Release
 

Part 14 - Clam Antivirus & SpamAssassin
(Debian)

Alright, the next 2 steps are going to be the trickiest of the entire installation. First, on this page, we're going to install Clam Antivirus and Spamassassin. Then, on the next page, we will install qmail-scanner which will tie ClamAV and Spamassassin into the operation of our qmail server. I'm going to warn you again that these next two steps are typically a pain in the ass. I am constantly trying to make these steps as universal and easy as possible, but the ease of these steps depends heavily on how your system is configured and how experienced you are. If you've never done this before, you can pretty much bet you're going to have a problem or 2 along the way. But don't give up. If you get into a bind, feel free to consult the qmailrocks mailing list, mailing list archive, IRC channel or chat forum. Using these 4 resources, you've got an excellent chance of getting any help you may need. OK, it's time to put some hair on your chest!

First, let's make sure you have all the required perl modules and required packages. All of the perl modules below are required for Spamassassin and Qmail-Scanner to work. I'll talk more about this further down in the install.

The following Perl Modules/packages are required:

Digest::SHA1
Digest::HMAC

Net::DNS
Time::HiRes
HTML::Tagset
HTML::Parser

Pod::Usage
Parse::Syslog

Interpreters::Storable
Statistics::Distributions

You will also need these other packages:

perl-suid
unzip

- Helpful Hints -

Checking/Installing Perl Modules

How do I know if my server has these perl modules?

The following script will check your system for the above modules.

You MUST run this script as a NON-ROOT user!!

/downloads/qmailrocks/scripts/util/check_perlmods.script

If you see an output similar to this: /usr/local/lib/perl5/site_perl/5.6.1/mach/Time/HiRes.pm , you're good to go! However, if you get a "not found" type response for any of the above modules, you will need to install them.

Ok, so if I don't have the module(s), how do I down and install it(them)?

Apt-get makes easy work of this. Here's the syntax for installing each of the above modules:

apt-get install libdigest-sha1-perl

apt-get install libdigest-hmac-perl

apt-get install libnet-dns-perl

apt-get install libtime-hires-perl

apt-get install libhtml-parser-perl

apt-get install libparse-syslog-perl

apt-get install libstorable-perl

Viola! All better.

Ok, so at this point you should have all 4 of the above Perl modules installed on your system. So let's install Clam Anti Virus and then Spammassin..

Installing Clam Anti Virus..

cd /downloads/qmailrocks/

tar zxvf clamav-x.xx..tar.gz

cd clamav-x.xx

useradd -s /sbin/nologin -d /tmp clamav

groupadd clamav

useradd -s /sbin/nologin -d /bin/false qscand

groupadd qscand

./configure --prefix=/usr --sysconfdir=/etc

make && make check && make install

mkdir /var/log/clamav /var/lib/clamav

chown -R clamav:clamav /var/log/clamav /var/lib/clamav

Now we'll do a few configuration settings to the /etc/clamd.conf file...

vi /etc/clamd.conf

"Example" - should be commented out.
"LogFile" - should be set to /var/log/clamav/clamd.log
"LogTime" - should be uncommmented.
"LogSyslog" - should be uncommented.

"PidFile" - should be uncommented and set to /var/run/clamav/clamd.pid
"User" - should be set to qscand

"ScanMail" - should be uncommented.

And some settings to the /etc/freshclam.conf file...

vi /etc/freshclam.conf

"Example" - should be commented out.
DatabaseDirectory - should be uncommented and set to /var/lib/clamav

Ok, Clam AV is now installed, but let's go ahead and set it up so that it will auto-update every night with the latest virus definitions! First we will want to set up the proper logging for the updater....

/usr/bin/freshclam -l /var/log/clamav/clam-update.log

If the server is able to get updates, you should see an output similar to this:

ClamAV update process started at Thu Dec 16 16:14:51 2004
Downloading main.cvd [*]
main.cvd updated (version: 28, sigs: 26630, f-level: 3, builder: tomek)
Downloading daily.cvd [*]
daily.cvd updated (version: 633, sigs: 1794, f-level: 3, builder: tkojm)
Database updated (28424 signatures) from database.clamav.net (24.73.112.74).

Woohoo! You're updated with the latest virus definiations from the Clam database!

Now we just set a crontab to run every night, which will run the auto-update procedure! In the example below, I've set mine to run every day at 1:35 AM. The odd run time came reccomended from ClamAV, if you're wondering. Running freshclam at times other than the top of an hour reduces the load on their servers. so feel free to adjust the time to something even more offbeat, like 1:33 AM or something. The guys at ClamAV will thank you.

crontab -e (make sure you run this command as root)

35 1 * * * /usr/bin/freshclam --quiet -l /var/log/clamav/clam-update.log

Now save your new crontab and exit.

Now we need to create an init script for clamd...

cp /downloads/qmailrocks/scripts/misc/debian_clamd /etc/init.d/clamd

mkdir /var/run/clamav

chown -R qscand:qscand /var/run/clamav

And now let's crank up clamd...

/etc/init.d/clamd stop

/etc/init.d/clamd start

If clamd has started successfully, a "ps -aux | grep clamd " command should reveal it...

qscand 11613 0.0 0.5 5972 4984 ? S 07:17 0:00 /usr/sbin/clamd

Once you have clamd successfully operating, let's configure the server so that clamd will start up on boot. Fortunately, Debian has a utility made just for doing this..

update-rc.d clamd start 75 2 3 4 5 .

The above command should create the needed init symlinks for the 2, 3, 4 and 5 runlevels. You're all set!

We're all done with Clam AV. Now let's install SpamAssassin...

cd /downloads/qmailrocks

tar zxvf Mail-SpamAssassin-3.0.2.tar.gz

cd Mail-SpamAssassin-3.0.2

perl Makefile.PL (answer all questions. Use the default answers provided if you are unsure)

make && make install

Ok, Spamassassin is installed. Let's make some tweaks. First, we're going to add a user/group called "spamd" under which Spamassassin will be run...

groupadd spamd

useradd -g spamd -s /bin/false -m -d /home/spamassassin spamd

Next, we set the spam threshold value and rewrite subject variable...

vi /etc/mail/spamassassin/local.cf

Replace the contents of the local.cf file with the following config settings:

rewrite_subject 1
required_hits 5

Save and exit from the file.

And now, let's put a Spamassassin startup script in place...

cp /downloads/qmailrocks/scripts/misc/debian_spamd /etc/init.d/spamd

mkdir /var/run/spamd

chown -R spamd:spamd /var/run/spamd

The init script contains a variable specifying the location of spamd. Let's make sure it's correct. First, find out where spamd resides...

whereis spamd

You should get an answer like /usr/local/bin/spamd or /usr/bin/spamd or something like that. Make a note of where spamd is located.

Now, open the /etc/init/dspamd init script for editing....

vi /etc/init.d/spamd

Make sure that the following variable reflect the correct location of spamd:

DAEMON=/correct/path/to/spamd

And now let's crank up Spamassassin...

/etc/init.d/spamd stop

/etc/init.d/spamd start

If spamd has started successfully, a "ps -aux | grep spam " command should reveal it...

spamd 283 0.0 2.1 21152 19328 ? S 04:33 0:01 /usr/local/bin/spamd -x -u spamd -H /home/spamd -d --pidfile=/var/run/spamd/spamd.pid
spamd 339 0.0 2.1 21152 19328 ? S 04:33 0:00 spamd child
spamd 340 0.0 2.1 21152 19328 ? S 04:33 0:00 spamd child
spamd 341 0.0 2.1 21152 19328 ? S 04:33 0:00 spamd child
spamd 342 0.0 2.1 21152 19328 ? S 04:33 0:00 spamd child
spamd 343 0.0 2.1 21152 19328 ? S 04:33 0:00 spamd child

Once you have spamassin successfully operating, let's configure the server so that spamd will start up on boot. We'll do this just like we did with clamd...

update-rc.d spamd start 75 2 3 4 5 .

The above command should create the needed init symlinks for the 2, 3, 4 and 5 runlevels. You're all set!

If all has gone well, both Spamassassin and Clam Anti Virus should now be installed! With both of these programs installed, we can now install qmail-scanner.

Proceed to Part 15

 

Color Coded Qmail Installation Key
 
Regular Black Text 
 Qmail installation notes and summaries by the author. Me talking.
 
Bold Black Text 
 Commands to be run by you, the installer.
 
Bold Maroon Text 
 Special notes for Redhat 9 users.
 
Bold Red Text 
 Vital and/or critical information.
 
Regular/Bold Purple text 
 Denotes helpful tips and hints or hyperlinks.
 
Regular Orange Text 
 Command line output.
Cp

Regular green text 

 Denotes the contents of a file or script.
home | about | the installation | utilities | faq | contact | journal | mailing list | list archive | forum | links | donatemerchandise
modified
This mirror last modified: Thursday, August 9th, 2012 15:58:50 CEST
 
The Rocks Project