Installing Maia Mailguard On Debian Squeeze (Virtual Users/Domains With Postfix/MySQL) - Page 2

Want to support HowtoForge? Become a subscriber!
 
Submitted by Terrible Monster (Contact Author) (Forums) on Wed, 2011-12-07 17:17. ::

6 Maia Mailguard Configuration Test

Now run

cd /var/lib/amavis/maia/scripts/
./configtest.pl

This script checks if all Perl modules that are needed by amavisd-maia, SpamAssassin, and Maia Mailguard's maintenance scripts are installed. For me the output was as follows:

server1:/var/lib/amavis/maia/scripts# ./configtest.pl

MAIA MAILGUARD CONFIGURATION TEST

This script checks for the presence of applications and Perl modules
required by maiad, SpamAssassin, and Maia Mailguard's maintenance
scripts.  Version numbers are also checked, and if a newer version of
a component is recommended, you should consider upgrading to at least
the minimum recommended version.

If you have already configured your Maia Mailguard database, the script
will also test the connection to that database.

Remember also to run the configtest.php script on your web server to
perform similar tests of your web, PHP, and PEAR environment.

Application/Module       Version    Status
========================================================================
Perl                   :   5.10.1 : OK
file(1)                :     5.04 : OK
Archive::Tar           :     1.52 : OK
Archive::Zip           :     1.30 : OK
BerkeleyDB             :     0.42 : OK
Compress::Zlib         :     2.02 : OK
Convert::TNEF          :     0.17 : OK
Convert::UUlib         :     1.12 : OK
Crypt::Blowfish        :      N/A : NOT INSTALLED (Maia Mailguard's optional encryption feature requires this)
Crypt::CBC             :      N/A : NOT INSTALLED (Maia Mailguard's optional encryption feature requires this)
Crypt::OpenSSL::RSA    :     0.25 : OK
Data::UUID             :      N/A : NOT INSTALLED (required by Maia Mailguard)
DB_File                :     1.82 : OK
DBD::mysql             :    4.016 : OK
DBD::Pg                :      N/A : NOT INSTALLED (required if you use PostgreSQL as your Maia Mailguard database)
DBI                    :    1.612 : OK
Digest::MD5            :     2.39 : OK
Digest::SHA            :     5.47 : OK
Digest::SHA1           :     2.13 : OK
Encode::Detect         :      N/A : NOT INSTALLED (SpamAssassin's optional normalize_charset feature requires this)
File::Spec             :      3.3 : OK
forks                  :      N/A : NOT INSTALLED (required by Maia Mailguard's process-quarantine tool)
HTML::Parser           :     3.66 : OK
HTTP::Date             :    5.831 : OK
IO::Stringy            :    2.110 : OK
IO::Socket::INET6      :     2.65 : OK
IO::Zlib               :     1.09 : OK
IP::Country::Fast      :      N/A : NOT INSTALLED (SpamAssassin's optional RelayCountry plugin requires this)
libdb                  :      4.8 : OK
LWP                    :    5.836 : OK
Mail::Address          :     2.06 : OK
Mail::DKIM             :     0.38 : OK
Mail::Internet         :     2.06 : OK
Mail::SpamAssassin     :    3.3.1 : OK
Mail::SPF              :    2.007 : OK
MIME::Base64           :     3.08 : OK
MIME::Parser           :    5.428 : OK
MIME::QuotedPrint      :     3.08 : OK
Net::CIDR::Lite        :      N/A : NOT INSTALLED (SpamAssassin's optional SPF plugin requires this)
Net::Cmd               :     2.29 : OK
Net::DNS               :     0.66 : OK
Net::Server            :     0.97 : OK
Net::SMTP              :     2.31 : OK
NetAddr::IP            :    4.028 : OK
Pod::Usage             :     1.36 : OK
Razor2::Client::Agent  :     2.84 : OK
Template               :      N/A : NOT INSTALLED (required by Maia Mailguard)
Time::HiRes            :   1.9719 : OK
Unix::Syslog           :      1.1 : OK
URI                    :     1.54 : OK
Text::CSV              :      N/A : NOT INSTALLED (required by maiadbtool.pl)
MySQL Server           :   5.1.49 : OK
Database DSN test      : PASSED

Patch 'MySQL Bug 46675' needs to be applied (see http://www.maiamailguard.com/maia/ticket/565).
Patch file mysql-bug-46675.patch not found.
Download the patch from: http://www.maiamailguard.com/maia/raw-attachment/ticket/565/mysql-bug-46675.patch
To apply the patch, you will need to do the following as 'root':

   patch -d /usr/share/perl5/Mail/SpamAssassin/BayesStore MySQL.pm < mysql-bug-46675.patch

Run this configtest again afterward to confirm that the patch was applied successfully.
If the patching was successful this patch warning should no longer appear.
Restart maiad after patching is verified.

    NOTE: When upgrading Perl to version 5.10 or planning to do so, please
    do not forget to add a missing /m flag to regular expressions in your existing
    AV entries, as suggested in the example file maiad.conf.dist. Perl 5.8 does
    not mind missing /m flags, but with perl 5.10 the results from a virus scanner
    may no longer be properly recognized.
server1:/var/lib/amavis/maia/scripts#

Please note that Maia requires additional patching:

wget http://www.maiamailguard.com/maia/raw-attachment/ticket/565/mysql-bug-46675.patch
patch -d /usr/share/perl5/Mail/SpamAssassin/BayesStore MySQL.pm < mysql-bug-46675.patch

As you see a few modules are missing. Most of them can be installed via aptitude:

aptitude install libcrypt-blowfish-perl libcrypt-cbc-perl libcrypt-openssl-rsa-perl libmail-dkim-perl libmail-spf-query-perl libnet-cidr-lite-perl libtemplate-perl libtext-csv-perl g++

Quite a few PHP modules are not available as Debian Squeeze packages, so we must install them using the Perl shell:

perl -MCPAN -e shell

install YAML

install Crypt::Blowfish Crypt::CBC DBD::Pg Net::CIDR::Lite Template Text::CSV Data::UUID IP::Country::Fast Encode::Detect

install forks

Type

q

to leave the Perl shell afterwards.

Run

./configtest.pl

again - output should now be as follows:

server1:/var/lib/amavis/maia/scripts# ./configtest.pl

MAIA MAILGUARD CONFIGURATION TEST

This script checks for the presence of applications and Perl modules
required by amavisd-maia, SpamAssassin, and Maia Mailguard's maintenance
scripts.  Version numbers are also checked, and if a newer version of
a component is recommended, you should consider upgrading to at least
the minimum recommended version.

If you have already configured your Maia Mailguard database, the script
will also test the connection to that database.

Remember also to run the configtest.php script on your web server to
perform similar tests of your web, PHP, and PEAR environment.

Application/Module      Version   Status
========================================================================
Perl                 :   5.10.0 : OK
file(1)              :     4.26 : OK
Archive::Tar         :     1.38 : OK
Archive::Zip         :     1.18 : OK
BerkeleyDB           :     0.34 : OK
Compress::Zlib       :    2.012 : OK
Convert::TNEF        :     0.17 : OK
Convert::UUlib       :     1.11 : OK
Crypt::Blowfish      :     2.10 : OK
Crypt::CBC           :     2.29 : OK
Crypt::OpenSSL::RSA  :     0.25 : OK
Data::UUID           :    1.215 : OK
DB_File              :  1.816_1 : OK
DBD::mysql           :    4.007 : OK
DBD::Pg              :      N/A : NOT INSTALLED (required if you use PostgreSQL as your Maia Mailguard database)
DBI                  :    1.605 : OK
Digest::MD5          :  2.36_01 : OK
Digest::SHA1         :     2.11 : OK
File::Spec           :   3.2501 : OK
HTML::Parser         :     3.56 : OK
HTTP::Date           :    5.810 : OK
IO::Stringy          :    2.110 : OK
IO::Zlib             :     1.07 : OK
IP::Country          :     2.27 : OK
LWP::UserAgent       :    5.813 : OK
Mail::Address        :     2.03 : OK
Mail::DKIM           :     0.32 : OK
Mail::Internet       :     2.03 : OK
Mail::SpamAssassin   :    3.2.5 : OK
Mail::SPF::Query     :  1.999.1 : OK
MIME::Base64         :  3.07_01 : OK
MIME::Parser         :    5.427 : OK
MIME::QuotedPrint    :     3.07 : OK
Net::CIDR::Lite      :     0.20 : OK
Net::Cmd             :     2.29 : OK
Net::DNS             :     0.63 : OK
Net::Server          :     0.97 : OK
Net::SMTP            :     2.31 : OK
Pod::Usage           :     1.35 : OK
Template             :     2.19 : OK
Time::HiRes          :   1.9711 : OK
Unix::Syslog         :      1.1 : OK
URI                  :     1.35 : OK
Text::CSV            :     1.06 : OK

Database DSN test    : PASSED

    NOTE: When upgrading Perl to version 5.10 or planning to do so, please
    do not forget to add a missing /m flag to regular expressions in your existing
    AV entries, as suggested in the example file amavisd.conf.dist. Perl 5.8 does
    not mind missing /m flags, but with perl 5.10 the results from a virus scanner
    may no longer be properly recognized.
server1:/var/lib/amavis/maia/scripts#

Since we are using MySQL and not PostgreSQL, we don't need the DBD::Pg module.

 

7 Loading SpamAssassin Rules

Maia Mailguard needs to index all of the SpamAssassin rules you have installed on your system. This can be done as follows:

./load-sa-rules.pl --debug

This should be done again whenever your SpamAssassin rules are updated. If you've followed the Virtual Users And Domains With Postfix, Courier, MySQL And SquirrelMail (Debian Squeeze) tutorial, you have the following cron job on your system:

23 4 */2 * * /usr/bin/sa-update --no-gpg &> /dev/null

Run

crontab -e

to modify that cron job so that it looks as follows:

23 4 */2 * * /usr/bin/sa-update --no-gpg && /var/lib/amavis/maia/scripts/load-sa-rules.pl && /etc/init.d/amavis restart &> /dev/null

 

8 Installing The Maia Mailguard Web Interface

I want to install Maia's web interface in /var/www/maia so that it can be accessed via http://www.example.com/maia (please adjust the path if your document root is different from /var/www). Therefore I create that directory now and copy Maia's web interface to it:

mkdir /var/www/maia
cp -pfr /usr/src/maia/1.0/php/* /var/www/maia/

Certain subdirectories of the /var/www/maia/themes directory must be writable by the Apache user. This can be achieved as follows:

chgrp amavis /var/www/maia/themes/*/compiled
chmod 775 /var/www/maia/themes/*/compiled
gpasswd -a www-data amavis

Maia's web interface uses the Smarty template engine which can be installed as follows:

aptitude install smarty

ln -s /usr/share/php/smarty/libs /usr/share/php/Smarty

Next we rename /var/www/maia/config.php.dist to /var/www/maia/config.php...

mv /var/www/maia/config.php.dist /var/www/maia/config.php

... and change the following settings:

nano /var/www/maia/config.php

[...]
    $maia_sql_dsn = "mysql://amavis:amavismysqlpasswd@tcp(localhost:3306)/maia";
[...]
    $address_rewriting_type = 4;
[...]
    // Select an authentication method from one of the following:
    //
    //    "pop3"     - use a POP3 server to authenticate
    //    "imap"     - use an IMAP server to authenticate
    //    "ldap"     - use an LDAP server to authenticate
    //    "exchange" - use an Exchange Server to authenticate
    //    "sql"      - use a SQL database server to authenticate
    //    "internal" - use Maia's internal SQL database to authenticate
    $auth_method = "pop3";
[...]

Run

chmod 0640 /var/www/maia/config.php
chown root:www-data /var/www/maia/config.php

afterwards.

 

9 Testing Your PHP Configuration

Open a browser and go to http://www.example.com/maia/admin/configtest.php. This page tells you if all needed PHP modules are installed:

If modules are missing, you must install them now. I had to do the following to install the missing modules:

aptitude install php-pear

pear channel-update pear.php.net

pear install Mail_Mime
pear install Mail_mimeDecode
pear install Pager
pear install Net_Socket
pear install Net_SMTP
pear install Auth_SASL
pear install Net_IMAP
pear install Net_POP3
pear install Log
pear install Image_Color
pear install Image_Canvas-0.3.1
pear install Image_Graph-0.7.2

cd /usr/share/php/Image/Graph/Plot/
cp Pie.php Pie.php.original
wget http://www.maiamailguard.org/maia/raw-attachment/ticket/326/Pie.php.patch
patch -p0<Pie.php.patch

pear install Numbers_Roman
pear install Numbers_Words-0.16.1

pear channel-discover htmlpurifier.org
pear install hp/HTMLPurifier

aptitude install php5-imap php5-ldap php5-mcrypt

/etc/init.d/lighttpd restart

Now reload http://www.example.com/maia/admin/configtest.php - all required modules should now be installed:


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.