How to Fix “./install.sh: line 107: rpmbuild: command not found” Error When Install MailScanner

mailscannerThis guide shows the common error when linux administrator trying to install the mailscanner using ./install.sh script. But you can easily address the problem by reading the error log given and everything is logging into “install.log”. This guide may speed up the troubleshooting time for newbie who not familiar with linux and Mailscanner package and software.

Question : When i try to install MailScanner on CentOS 6.3, i get the following error :

[root@mx1 MailScanner-4.84.5-3]# ./install.sh

I am logging everything into "install.log".


Good. You have the patch command.

./install.sh: line 107: rpmbuild: command not found
Your /usr/src/redhat, /usr/src/RPM or /usr/src/packages
tree is missing.
If you have access to an RPM called rpm-build or rpmbuild
then install it first and come back and try again.

Solution :

From the error above, rpmbuild command not found in the system caused the error. This software is the prerequisite software and if you want to install using install.sh shell scrip.

./install.sh: line 107: rpmbuild: command not found

Just run the following command to install rpmbuild on linux CentOS 6.3 :

[root@mx1 MailScanner-4.84.5-3]# yum install rpm-build -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.sin3.sg.voxel.net
 * epel: ftp.cuhk.edu.hk
 * extras: mirrors.sin3.sg.voxel.net
 * updates: ossm.utm.my
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package rpm-build.x86_64 0:4.8.0-27.el6 will be installed
--> Processing Dependency: elfutils >= 0.128 for package: rpm-build-4.8.0-27.el6.x86_64
--> Processing Dependency: xz for package: rpm-build-4.8.0-27.el6.x86_64
--> Processing Dependency: unzip for package: rpm-build-4.8.0-27.el6.x86_64
--> Processing Dependency: pkgconfig for package: rpm-build-4.8.0-27.el6.x86_64
--> Processing Dependency: lzma for package: rpm-build-4.8.0-27.el6.x86_64
--> Processing Dependency: /usr/bin/gdb-add-index for package: rpm-build-4.8.0-27.el6.x86_64
--> Running transaction check
---> Package elfutils.x86_64 0:0.152-1.el6 will be installed
--> Processing Dependency: elfutils-libs(x86-64) = 0.152-1.el6 for package: elfutils-0.152-1.el6.x86_64
--> Processing Dependency: libdw.so.1(ELFUTILS_0.149)(64bit) for package: elfutils-0.152-1.el6.x86_64
--> Processing Dependency: libdw.so.1(ELFUTILS_0.148)(64bit) for package: elfutils-0.152-1.el6.x86_64
--> Processing Dependency: libdw.so.1(ELFUTILS_0.138)(64bit) for package: elfutils-0.152-1.el6.x86_64
--> Processing Dependency: libdw.so.1(ELFUTILS_0.127)(64bit) for package: elfutils-0.152-1.el6.x86_64
--> Processing Dependency: libdw.so.1(ELFUTILS_0.126)(64bit) for package: elfutils-0.152-1.el6.x86_64
--> Processing Dependency: libdw.so.1(ELFUTILS_0.122)(64bit) for package: elfutils-0.152-1.el6.x86_64
--> Processing Dependency: libasm.so.1(ELFUTILS_1.0)(64bit) for package: elfutils-0.152-1.el6.x86_64
--> Processing Dependency: libdw.so.1()(64bit) for package: elfutils-0.152-1.el6.x86_64
--> Processing Dependency: libasm.so.1()(64bit) for package: elfutils-0.152-1.el6.x86_64
---> Package gdb.x86_64 0:7.2-56.el6 will be installed
---> Package pkgconfig.x86_64 1:0.23-9.1.el6 will be installed
---> Package unzip.x86_64 0:6.0-1.el6 will be installed
---> Package xz.x86_64 0:4.999.9-0.3.beta.20091007git.el6 will be installed
---> Package xz-lzma-compat.x86_64 0:4.999.9-0.3.beta.20091007git.el6 will be installed
--> Running transaction check
---> Package elfutils-libs.x86_64 0:0.152-1.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================
 Package                     Arch                Version                                        Repository         Size
========================================================================================================================
Installing:
 rpm-build                   x86_64              4.8.0-27.el6                                   base              125 k
Installing for dependencies:
 elfutils                    x86_64              0.152-1.el6                                    base              201 k
 elfutils-libs               x86_64              0.152-1.el6                                    base              181 k
 gdb                         x86_64              7.2-56.el6                                     base              2.3 M
 pkgconfig                   x86_64              1:0.23-9.1.el6                                 base               70 k
 unzip                       x86_64              6.0-1.el6                                      base              149 k
 xz                          x86_64              4.999.9-0.3.beta.20091007git.el6               base              137 k
 xz-lzma-compat              x86_64              4.999.9-0.3.beta.20091007git.el6               base               16 k

Transaction Summary
========================================================================================================================
Install       8 Package(s)

Total download size: 3.1 M
Installed size: 7.5 M
Downloading Packages:
(1/8): elfutils-0.152-1.el6.x86_64.rpm                                                           | 201 kB     00:02
(2/8): elfutils-libs-0.152-1.el6.x86_64.rpm                                                      | 181 kB     00:03
(3/8): gdb-7.2-56.el6.x86_64.rpm                                                                 | 2.3 MB     00:40
(4/8): pkgconfig-0.23-9.1.el6.x86_64.rpm                                                         |  70 kB     00:01
(5/8): rpm-build-4.8.0-27.el6.x86_64.rpm                                                         | 125 kB     00:01
(6/8): unzip-6.0-1.el6.x86_64.rpm                                                                | 149 kB     00:02
(7/8): xz-4.999.9-0.3.beta.20091007git.el6.x86_64.rpm                                            | 137 kB     00:02
(8/8): xz-lzma-compat-4.999.9-0.3.beta.20091007git.el6.x86_64.rpm                                |  16 kB     00:00
------------------------------------------------------------------------------------------------------------------------
Total                                                                                    58 kB/s | 3.1 MB     00:55
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : xz-4.999.9-0.3.beta.20091007git.el6.x86_64                                                           1/8
  Installing : xz-lzma-compat-4.999.9-0.3.beta.20091007git.el6.x86_64                                               2/8
  Installing : 1:pkgconfig-0.23-9.1.el6.x86_64                                                                      3/8
  Installing : gdb-7.2-56.el6.x86_64                                                                                4/8
  Installing : elfutils-libs-0.152-1.el6.x86_64                                                                     5/8
  Installing : elfutils-0.152-1.el6.x86_64                                                                          6/8
  Installing : unzip-6.0-1.el6.x86_64                                                                               7/8
  Installing : rpm-build-4.8.0-27.el6.x86_64                                                                        8/8
  Verifying  : unzip-6.0-1.el6.x86_64                                                                               1/8
  Verifying  : xz-lzma-compat-4.999.9-0.3.beta.20091007git.el6.x86_64                                               2/8
  Verifying  : elfutils-libs-0.152-1.el6.x86_64                                                                     3/8
  Verifying  : elfutils-0.152-1.el6.x86_64                                                                          4/8
  Verifying  : gdb-7.2-56.el6.x86_64                                                                                5/8
  Verifying  : rpm-build-4.8.0-27.el6.x86_64                                                                        6/8
  Verifying  : xz-4.999.9-0.3.beta.20091007git.el6.x86_64                                                           7/8
  Verifying  : 1:pkgconfig-0.23-9.1.el6.x86_64                                                                      8/8

Installed:
  rpm-build.x86_64 0:4.8.0-27.el6

Dependency Installed:
  elfutils.x86_64 0:0.152-1.el6                                    elfutils-libs.x86_64 0:0.152-1.el6
  gdb.x86_64 0:7.2-56.el6                                          pkgconfig.x86_64 1:0.23-9.1.el6
  unzip.x86_64 0:6.0-1.el6                                         xz.x86_64 0:4.999.9-0.3.beta.20091007git.el6
  xz-lzma-compat.x86_64 0:4.999.9-0.3.beta.20091007git.el6

Complete!

You can re-run the ./install.sh command when rpmbuild installation completed as above.

How to Setup MailWatch on CentOS 6.3

mailwatch logoMailWatch for MailScanner is a open source or free web-based front-end to Mailscanner that use to displays the inbound/outbound mail queue, spam, viruses and blocked content on each page header. MailWatch has been written in PHP, MySQL and JpGraph. By using Mailwatch, it allows you to delete, release or run sa-learn across any messages that was quarantined. This post describes how to setup MailWatch on CentOS 6.3 and assumed that you already installed MailScanner and postfix.

1. Install required php and mysql :

[root@mx1 ~]# yum install php mysql-server mysql php-gd php-mysql -y

2. Modify the php.ini :

[root@mx1 ~]# vim /etc/php.ini

PHP should have the following set in php.ini

 short_open_tag = On
 safe_mode = Off
 register_globals = Off
 magic_quotes_gpc = On
 magic_quotes_runtime = Off
 session.auto_start = 0

3. Download the latest version from mailwatch.sourceforge.net :

[root@mx1 ~]# wget http://sourceforge.net/projects/mailwatch/files/mailwatch/1.1.5.1/mailwatch-1.1.5.1.tar.gz

4. Extract downloaded mailwatch package :

[root@mx1 ~]# tar xzvf mailwatch-1.1.5.1.tar.gz

5. Start mysql service :

[root@mx1 ~]# service mysqld start
Initializing MySQL database:  WARNING: The host 'mx1.ehowstuff.local' could not be looked up with resolveip.
This probably means that your libc libraries are not 100 % compatible
with this binary MySQL version. The MySQL daemon, mysqld, should work
normally with the exception that host name resolving will not work.
This means that you should use IP addresses instead of hostnames
when specifying MySQL privileges !
Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h mx1.ehowstuff.local password 'new-password'

Alternatively you can run:
/usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/bin/mysqlbug script!

                                                           [  OK  ]
Starting mysqld:                                           [  OK  ]

6. Enter extracted mailwatch-x.x directory :

[root@mx1 mailwatch-1.1.5.1]# ls
CHANGELOG   fix_quarantine_permissions  LICENSE  mailscanner               Remote_DB.txt  upgrade.php  USER_FILTERS
create.sql  INSTALL                     luser    MailScanner_perl_scripts  tools          UPGRADING
[root@mx1 mailwatch-1.1.5.1]# mysql -p < create.sql

7. Create the database and import create.sql. The following commands below should be run as the ‘root’ :

[root@mx1 mailwatch-1.1.5.1]# mysql -p < create.sql
Enter password:

8. Login to mysql as a root :

[root@mx1 mailwatch-1.1.5.1]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.1.67 Source distribution

Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

9. Proceed to create a MySQL user and then set password and configure MailScanner for SQL logging :

mysql> GRANT ALL ON mailscanner.* TO mailwatch@localhost IDENTIFIED BY 'password';
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT FILE ON *.* TO mailwatch@localhost IDENTIFIED BY 'password';
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mailscanner        |
| mysql              |
| test               |
+--------------------+
4 rows in set (0.00 sec)

10. Edit MailWatch.pm and change the database values accordingly :

a. Enter to the perl_scripts’s folder :

[root@mx1 mailwatch-1.1.5.1]# cd MailScanner_perl_scripts
[root@mx1 MailScanner_perl_scripts]# pwd
/root/mailwatch-1.1.5.1/MailScanner_perl_scripts

b. Edit MailWatch.pm :

[root@mx1 MailScanner_perl_scripts]# vim MailWatch.pm

c.Modify this as necessary for your configuration

my($db_name) = 'mailscanner';
my($db_host) = 'localhost';
my($db_user) = 'mailwatch';
my($db_pass) = 'password';

11. Move MailWatch.pm to /usr/lib/MailScanner/MailScanner/CustomFunctions :

[root@mx1 MailScanner_perl_scripts]# cp MailWatch.pm /usr/lib/MailScanner/MailScanner/CustomFunctions

12. Create a MailWatch web user. This user will able to monitor the mailscanner through MailWatch web interface.

[root@mx1 ~]# mysql mailscanner -u mailwatch -p
Enter password:
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.1.67 Source distribution

Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> INSERT INTO users SET username = 'admin', password = md5('password'), fullname = 'MAilwatch Administrator', type ='A';
Query OK, 1 row affected (0.00 sec)

13. Install & Configure MailWatch :
a. Enter to mailwatch directory :

[root@mx1 ~]# cd mailwatch-1.1.5.1

b. Move mailscanner folder for web root folder. For apache, default root folder is /var/www/html :

[root@mx1 mailwatch-1.1.5.1]# mv mailscanner /var/www/html/

c. Enter to mailscanner folder in web root directory :

[root@mx1 ~]# cd /var/www/html/mailscanner

d. Verify and check the permissions of /var/www/html/mailscanner/images and /var/www/html/images/cache. The permissions and ownerships should be as below :

[root@mx1 mailscanner]# chown root:apache images
[root@mx1 mailscanner]# chmod ug+rwx images
[root@mx1 mailscanner]# chown root:apache images/cache
[root@mx1 mailscanner]# chmod ug+rwx images/cache

14. Create conf.php by copying conf.php.example. Edit the values to any details as you created earlier :

a. Copy the conf.php :

[root@mx1 mailscanner]# cp conf.php.example conf.php

b. Open conf.php :

[root@mx1 mailscanner]# vim conf.php

c. Edit the details as below :

define('DB_TYPE', 'mysql');
define('DB_USER', 'mailwatch');
define('DB_PASS', 'password');
define('DB_HOST', 'localhost');
define('DB_NAME', 'mailscanner');

15. Before setup the mailscanner, make sure it’s Stopped. Run 3 to 4 times to ensure the mailscanner completely stop. The status will FAILED if mailscanner completely stop.

[root@mx1 ~]# service MailScanner stop
Shutting down MailScanner daemons:
         MailScanner:                                      [  OK  ]
         incoming postfix:                                 [  OK  ]
         outgoing postfix:                                 [  OK  ]
[root@mx1 ~]# service MailScanner stop
Shutting down MailScanner daemons:
         MailScanner:                                      [  OK  ]
         incoming postfix:                                 [  OK  ]
         outgoing postfix:                                 [  OK  ]
[root@mx1 ~]# service MailScanner stop
Shutting down MailScanner daemons:
         MailScanner:                                      [  OK  ]
         incoming postfix:                                 [  OK  ]
         outgoing postfix:                                 [  OK  ]
[root@mx1 ~]# service MailScanner stop
Shutting down MailScanner daemons:
         MailScanner:                                      [  OK  ]
         incoming postfix:                                 [  OK  ]
         outgoing postfix:                                 [  OK  ]
[root@mx1 ~]# service MailScanner stop
Shutting down MailScanner daemons:
         MailScanner:                                      [FAILED]
         incoming postfix:                                 [  OK  ]
         outgoing postfix:                                 [  OK  ]

16. Edit /etc/MailScanner/MailScanner.conf.

[root@mx1 ~]# vim /etc/MailScanner/MailScanner.conf

Make sure that the following options are set:

 Always Looked Up Last = &MailWatchLogging
 Detailed Spam Report = yes
 Quarantine Whole Message = yes
 Quarantine Whole Message As Queue Files = no
 Include Scores In SpamAssassin Report = yes
 Quarantine User = root
 Quarantine Group = apache (this should be the same group as your web server)
 Quarantine Permissions = 0660

17. Start MailScanner :

[root@mx1 ~]# service MailScanner start
Starting MailScanner daemons:
         incoming postfix:                                 [  OK  ]
         outgoing postfix:                                 [  OK  ]
         MailScanner:                                      [  OK  ]

18. Restart httpd service :

[root@mx1 ~]# service httpd restart

19. Make sure all the related service such as httpd, mysql and MailScanner configured to start at boot :

[root@mx1 ~]# chkconfig mysqld on
[root@mx1 ~]# chkconfig httpd on
[root@mx1 ~]# chkconfig MailScanner on
[root@mx1 ~]# chkconfig spamassassin on
[root@mx1 ~]# chkconfig postfix on

20. Check the mail log.

[root@mx1 ~]# tail -f /var/log/maillog

You should see something as below :

Mar  5 22:14:42 mx1 MailScanner[1718]: Using locktype = flock
Mar  5 22:14:43 mx1 MailScanner[1697]: Requeue: C297BA1C3F.AA850 to E7373A1DD6
Mar  5 22:14:43 mx1 postfix/qmgr[1687]: E7373A1DD6: from=<root@mx1.ehowstuff.local>, size=609, nrcpt=1 (queue active)
Mar  5 22:14:43 mx1 MailScanner[1697]: Uninfected: Delivered 1 messages
Mar  5 22:14:43 mx1 MailScanner[1697]: Deleted 1 messages from processing-database
Mar  5 22:14:43 mx1 MailScanner[1697]: Logging message C297BA1C3F.AA850 to SQL
Mar  5 22:14:43 mx1 postfix/local[1768]: E7373A1DD6: to=<root@mx1.ehowstuff.local>, orig_to=, relay=local, delay=166894, delays=166894/0.13/0/0.02, dsn=2.0.0, status=sent (delivered to mailbox)
Mar  5 22:14:43 mx1 postfix/qmgr[1687]: E7373A1DD6: removed
Mar  5 22:56:25 mx1 postfix/postfix-script[1869]: fatal: the Postfix mail system is already running
Mar  5 23:01:08 mx1 update.bad.phishing.sites: Delaying cron job up to 600 seconds

21. Login to mailwatch web interface :
1

2