Mailwatch
Mailwatch is a program designed to give even more monitoring info about your MailScanner system. It's not available as a port but it's quite easy to setup.
Pre-requisites
Apache needs to be installed - if you've not already done it then:cd /usr/ports/www/apache13 make install cd /usr/local/etc/apache edit httpd.conf
change ServerAdmin to point to a "real" email address - eg webmaster@cnwl.ac.uk
To make Apache auto-start, edit /etc/rc.conf and add
apache_enable="YES"
Now install MySQL
cd /usr/ports/databases/mysql50-server make install
When this finishes, edit /etc/rc.conf and add the line mysql_enable="YES" so that MySQL will auto-start.
Install PHP for Apache:
cd /usr/ports/www/mod_php5 make install
and accept the defaults. The FreeBSD port of the PHP module for Apache leaves out many PHP functions. To install the ones you need:
cd /usr/ports/devel/php5-pcre/ make install cd /usr/ports/databases/php5-mysql make install cd /usr/ports/graphics/php5-gd make install cd /usr/ports/mail/pear_
When it's finished you need to configure Apache to know about php. Open /usr/local/etc/apache/httpd.conf in edit and find the section
<IfModule mod_php4.c>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
</IfModule>
Copy this and paste it below, changing the _php4 to say _php5. Restart Apache to register these changes (apachectl graceful). Now create a file called test.php in the web root folder (this will be /usr/local/www/mailscanner-mrtg if you've followed all these instructions)
<?php phpinfo(); ?>
Browse to http://server/test.php and you should see info about your php installation.
Download mailwatch - I used the command:
wget http://kent.dl.sourceforge.net/sourceforge/mailwatch/mailwatch-1.0.3.tar.gz
but you should make sure that you use a local mirror (and note that the version number may change - follow the link from the Mailwatch home page to get the latest version). Unzip and untar it:
tar -xzf mailwatch-1.0.3.tar.gz
this will create a folder called MailWatch - change into it and type
mysql < create.sql to create the SQL database. Now start MySQL and create a user:MySQL
MySQL>GRANT ALL ON mailscanner.* TO mailwatch@localhost IDENTIFIED BY 'password';
MySQL>Quit;
mysql mailscanner -u mailwatch -ppassword
mysql> INSERT INTO users VALUES ('<username>',md5('<password>'),'<name>','A','0','0','0','0','0');
(Note the semi-colon at the end of the lines - MySQL doesn't execute a command until it gets to one and note that there's no space between the -p and the password for the mailwatch user.)
Copy the Perl module to the MailScanner custom function folder and then the main MailWatch folder to the web root
cp MailWatch.pm /usr/local/lib/MailScanner/MailScanner/CustomFunctions/ mv mailscanner /usr/local/www
Apache can host multiple web sites - I configured it so that the MRTG site was on port 80 and the mailwatch site was on port 8080. Edit httpd.conf and add
Listen 80 Listen 8080
to the Listen section and then add:
<VirtualHost *:8080> ServerAdmin postmaster@cnwl.ac.uk DocumentRoot /usr/local/www/mailscanner </VirtualHost>
to the end of the file with the other virtualhost directive. Restart Apache and browse to http://server:8080/index.php - you'll get an error message about conf.php but it shows that the site is present
In the web site folder, copy conf.php.example to conf.php and then edit it - set the values for user and password to the ones you used in the insert statement above. Edit the lines below:
define(MS_CONFIG_DIR, '/usr/local/etc/MailScanner/'); define(MS_LIB_DIR, '/usr/local/lib/MailScanner/'); define(SA_RULES_DIR, '/usr/local/share/spamassassin/');
