How to install and configure SpamAssassin with Postfix in Debian 8


1. Introduction

Spamassassin is a spam detection and prevention software intentionally made for incoming email spamming. We can prevent incoming spam mails by using various methods such as making content-matching rules. It flags an email as spam according to the resulting score of the mail which gets during the test.

In this article, We can see how to install and configure Spamassassin 3.4 in Debian 8.

2. Requirement

All the system softwares should be uptodate before starting the installation. Please follow the below commands to update your Debian system.

# apt-get update
# apt-get upgrade

3. Installation

After completing the software update, please install SpamAssassin using the following command :

# apt-get install spamc spamassassin

Thus the installation is completed. You can see the version by executing the commands below :

# spamassassin -V
SpamAssassin version 3.4.0
  running on Perl version 5.20.2

4. Setting Privileges

By default, The SpamAssasin will run under the root. We need to assign it to a low privileged user as a security measure. Executing the below commands one by one :

# groupadd -g 5555 spamd
# useradd -u 5555 -g spamd -s /sbin/nologin -d /usr/local/spamassassin spamd
# mkdir -p /usr/local/spamassassin/log
# chown spamd:spamd -R /usr/local/spamassassin

5. Enable SpamAssasin

To enable SpamAssassin daemon, Open the file /etc/default/spamassassin and edit the option ‘ENABLED=0’ to ‘ENABLED=1’.

6. Configure Spamassassin

Open the file given below :

# vi /etc/spamassassin/

Add or Change the following parameters and save the file.

rewrite_header Subject *****SPAM*****
required_score 3.0
report_safe 0
use_bayes 1
bayes_auto_learn 1

We have completed the Spamassassin configuration. Let see the postfix configuration.

7. Configure Postfix

Open the postfix file :

# vi /etc/postfix/

Search for the line given below :

smtp      inet  n       -       -       -       -       smtpd

Change the line as below :

smtp 	inet  n 	-	-	-	- 	smtpd -o content_filter=spamassassin

Then, add the following line at the end of the file :

spamassassin unix - n n - - pipe
  user=spamd argv=/usr/bin/spamc -f -e /usr/sbin/sendmail -oi -f ${sender} ${recipient}

Atlast, Save the file and restart the services :

# service spamassassin restart
# service postfix restart

Now you can see the SpamAssassin starts running :

# netstat -tnulp | grep spam
tcp 0 0* LISTEN 15972/spamassassin.

8. Conclusion

Thus we have completed the installation and configuration of SpamAssassin.

How to Install PostgreSQL on Debian 8

1. Introduction

PostgreSQL pronounced as “post-gress-Q-L” is a free and open source object-relational database management system. It is developed by a group of companies and some individuals. It supports almost all relational database features and offers a few unusual features that are normally absent in other RDBMS engines. Commonly supported objects include views, stored procedures, indexes, triggers and object-defined data types.

It is used by several web programming languages including PHP, and Python. These programming languages make is extremely easy to connect to a PostgreSQL database. It is also used for many content management scripts. It is very easy to store and retrieve information using SQL commands in PostgreSQL.

2. Advantages

  • It is a very powerful RDBMS system.
  • Cross Platform.
  • High stability and reliability.
  • It is highly programmable as well as extendible.
  • It has a strong third party support.
  • It supports a large number of data types.

3. Requirements

If you have a freshly installed debian 8 server with root access you are ready to install PostgreSQL 9.4.

In this article, We are going to install PostgreSQL and give you some introduction. So let’s start with the installation.

4. Installation

Here, We are going to install the PostgreSQL version. So we need to update the system with the latest updates.

Update the apt packages :

# apt-get update

You will see a message like the one below which means all the packages are been updated :

Reading package lists... Done

Now, Install PostgreSQL packages using apt-get :

# apt-get install postgresql-9.4 postgresql-client-9.4

At the end of the installation, you will get the information of configuration files, ports and further details. It will be like the one below.

Creating config file /etc/postgresql-common/createcluster.conf with new version

Creating config file /etc/logrotate.d/postgresql-common with new version
Building PostgreSQL dictionaries from installed myspell/hunspell packages...
Removing obsolete dictionary files:
Setting up postgresql-9.4 (9.4.5-0+deb8u1) ...
Creating new cluster 9.4/main ...
  config /etc/postgresql/9.4/main
  data   /var/lib/postgresql/9.4/main
  locale C
  port   5432
update-alternatives: using /usr/share/postgresql/9.4/man/man1/postmaster.1.gz to provide /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz) in auto mode
Processing triggers for libc-bin (2.19-18+deb8u1) ...
Processing triggers for systemd (215-17+deb8u2) ...

Thus the installation is completed.

Now we can confirm the installation using some commands. They are given below :

# root@name-debian8:~# ps -ef | grep postgre

This will provide you an output like the one below :

We can also check its status by the following commands :

~# netstat -tnulp | grep 5432
tcp        0      0*               LISTEN      17148/postgres  
tcp6       0      0 ::1:5432                :::*                    LISTEN      17148/postgres 

Thus we can confirm that the PostgreSQL is properly installed and running. Now, We can check accessing the database.

5. Accessing the Database

By default, a user and a database named postgres will be created during the installation. Also, We can only access the database by switching to that user postgres.

Switch to the PostgreSQL user by following the commands :

# su - postgres

Then get into the PostgreSQL console using the command pgsql :

postgres@name-debian8:~$ psql
psql (9.4.5)
Type "help" for help.

postgres=# \q
postgres@name-debian8:~$ exit

Now, You can exit from psql console by using \q and then exit command to logout from PostgreSQL.

6. Creating New Roles and Database

A role is an user, group or both that can own database objects and have database privileges. This will adds a new role to a PostgreSQL database cluster. Let’s see how to create a role.

Log in as the user postgres :

# su - postgress

Then use the following command to create a new role :

createuser --interactive

It will be an interactive session and ask you for the name of the role and whether it should be a superuser.

postgres@name-debian8:~$ createuser --interactive
Enter name of role to add: testpsql
Shall the new role be a superuser? (y/n) y

Thus we have successfully created a role.

In the same postgres terminal. Create a database using the command below. But please note that the database name should be same as the role.

postgres@name-debian8:~$ createdb testpsql 

The new database testpsql is now created.

7. Connecting to PostgreSQL

We have created an user and database called testpsql. Now, log in as the user testpsql and connect to the database.

# su - testpsql
No directory, logging in with HOME=/
$ psql
psql (9.4.5)
Type "help" for help.


Thus we have successfully connected to the database.

8. Conclusion

Thus we have installed the PostgreSQL in debian. You can check my upcoming post to know more about the working of PostgreSQL.

How to install Ioncube Loader on CentOS 7 or RHEL 7 or Debian 8

1. Introduction

Ioncube loader is a PHP module or extension which makes PHP files or websites more secure. It also helps in speeding up webpages. It encrypts PHP language and used for many other PHP applications.

2. Requirements

Before installing ioncube loader your server must have php installed on both CentOs 7 and Debian 8.

3. Download and extract Ioncube Loader

I will be downloading the 64-bit version of ioncube loader as my system is a 64-bit server.

# cd /usrlocal/src
# wget
# tar xfz ioncube_loaders_lin_x86-64.tar.gz

4. Configure ioncube loader

To configure ioncube we need to know which version of PHP is running.

Check the PHP version using the command:

# php -v
PHP 5.4.45 (cli) (built: Sep 30 2015 15:42:23) 
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies

Now check PHP extension directory using the following command

# php -i | grep extension_dir
extension_dir => /usr/lib64/php/modules => /usr/lib64/php/modules

Note: not all versions of PHP use the same location. It may be different for other servers. Use exact location that you get.

Open the ioncube folder and copy the ioncube loader file that matches your PHP version.

# ls /usr/local/src/ioncube
# cp /usr/local/src/ioncube/ /usr/lib64/php/modules

The next configuration step is a bit different for Centos and Debian/Ubuntu. We will have to add a line:

zend_extension = /usr/lib64/php/modules/

For CentOs 7:

Open the file /etc/php.ini and add the following line:

zend_extension = /usr/lib64/php/modules/

Now, restart the apache service.

# service httpd restart

For Debian 8:

In Debian there are separate php.ini files for PHP CLI, CGI, Apache2 and FPM mode such as:


Add zend_extension to the files and save:

zend_extension = /usr/lib/php5/20131226/

Now, restart apache service.

# service apache2 restart

5. Check result

In centos7

# php -v
PHP 5.4.45 (cli) (built: Sep 30 2015 15:42:23) 
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
    with the ionCube PHP Loader (enabled) + Intrusion Protection from (unconfigured) v5.0.19, Copyright (c) 2002-2015, by ionCube Ltd.

In Debian 8

# php -v
PHP 5.6.14-0+deb8u1 (cli) (built: Oct  4 2015 16:13:10) 
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
    with the ionCube PHP Loader (enabled) + Intrusion Protection from (unconfigured) v5.0.19, Copyright (c) 2002-2015, by ionCube Ltd.
  with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies

You can also check ioncube in the phpinfo() page in web browser.

Centos 7

Debian 8

How to install Malware Detect ( maldetect or LMD ) in Debian 8

1. Introduction

Malwares are kind of malicious software which damage the system, in order to avoid such harmful threats the user should aware of the changes that he is made in the server.
Linux Malware Detect(LMD) is a malware scanner for Linux released under the GNU GPLv2 license. It is a effective tool in order to find infected files and there by removing threats.

2. Download LMD archive latest version .

Go to /usr/local/src in which we can download the latest LMD.

# wget

3. Extract the downloaded file.

# tar -zxvf maldetect-current.tar.gz

Change present directory location to extracted directory

# cd maldetect-1.5

4. Run Installation Script

Install LMD by running the following script, it is the easiest way to do this installation part.

# ./

5. Edit configuration file

Open LMD main configuration file using vi editor and edit the following parameters.

#  vi /usr/local/maldetect/conf.maldet

Make sure the below value is enabled


To get mail alerts, make it to 1 else 0


The email id , in which you want to get alerts


Set default quarantine action for malware hits


To clean the detected malware


The default suspend action for users wih hits


The minimum userid value that can be suspended


6. Start scanning the system

Run following command to scan the system with LMD. Use maldet followed by directory which you want to scan.

# maldet -m /usr/local/
Linux Malware Detect v1.5
            (C) 2002-2015, R-fx Networks 
            (C) 2015, Ryan MacDonald 
This program may be freely redistributed under the terms of the GNU GPL v2

maldet(29347): {scan} signatures loaded: 10822 (8908 MD5 / 1914 HEX / 0 USER)
maldet(29347): {scan} building file list for /, this might take awhile...
maldet(29347): {scan} setting nice scheduler priorities for all operations: cpunice 19 , ionice 6
maldet(29347): {scan} file list completed in 0s, found 3070 files...
maldet(29347): {scan} scan of / (3070 files) in progress...
maldet(29347): {scan} 3070/3070 files scanned: 0 hits 0 cleaned
maldet(29347): {scan} scan completed on /: files 3070, malware hits 0, cleaned hits 0, time 96s
maldet(29347): {scan} scan report saved, to view run: maldet --report 160111-0858.29347

7. To Print the result

Print the number of infected files

# maldet --report 160111-0858.29347

HOST:      amal-debian8
SCAN ID:   160111-0858.29347
STARTED:   Jan 11 2016 08:58:50 +0300
COMPLETED: Jan 11 2016 09:00:26 +0300
ELAPSED:   96s [find: 0s]

PATH:          /

Linux Malware Detect v1.5 < >

8. Update virus Signature and LMD

Execute given commands to update virus signatures and LMD version.

Update virus signatures to latest

# maldet -u

This program may be freely redistributed under the terms of the GNU GPL v2

maldet(8348): {sigup} performing signature update check...
maldet(8348): {sigup} local signature set is version 2015121610247
maldet(8348): {sigup} latest signature set already installed

Update LMD to latest

# maldet -d

Linux Malware Detect v1.5
            (C) 2002-2015, R-fx Networks 
            (C) 2015, Ryan MacDonald 
This program may be freely redistributed under the terms of the GNU GPL v2

maldet(8237): {update} checking for available updates...
maldet(8237): {update} hashing install files and checking against server...
maldet(8237): {update} latest version already installed.

9. Remove infected files

Use following command to remove infected files
Reference: From previous scan my scan ID was 160111-0858.29347, it must be different for you. You can check this from your scan results.

# maldet -n 

How to install and configure LAMP ( Linux, Apache, MySQL and PHP ) in Ubuntu 14.04

1. Introduction

Short for Linux, Apache, MySQL and PHP, an open-source Web development platform, also called a Web stack, that uses Linux as the operating system, Apache as the Web server, MySQL as the RDBMS and PHP as the object-oriented scripting language. Perl or Python is often substituted for PHP.

2. Requirements

An ordinary server with Ubuntu 14.04 LTS installed. You can install it on any platform, but here the documentations are based on the Ubuntu / debian server.

3. Installation

Please proceed with the following steps:

3.1 Apache2 Installation

Type the below command for installing apache 2 package from repository.

#  apt-get install apache2

Restart apache service

# /etc/init.d/apache2 restart

Apache will start working with minimal configuration. Now Open your server-ip in the browser and You can see the apache ubuntu test page.( Default document root is located in this path /var/www/html )

apache3 ubuntu default

3.2 MySQL installation

Issue the below command to install mysql server with dependencies.

# apt-get install mysql-server

During installation it will prompt for a new password for mysql root . Give some strong password and retype the same password for confirmation.

After installation check the Database connection.

Check the service status.

# /etc/init.d/mysql status

Service is already up , Now Type this command to login

# mysql -u root -p

Enter password: ******
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 42
Server version: 5.5.35-1ubuntu1 (Ubuntu)
Copyright (c) 2000, 2013, 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
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

Mysql server installation is over.

3.3 PHP installation

Type the below command to install php5.

# apt-get install php5 php5-mysql

Create a php file and paste the below code into the file to show the php configuration . Goto the default apache root path /var/www/html . create a new file info.php and paste the below code and save it.

# vi /var/www/html/info.php

Please use the following codes to create a phpinfo page.


Now restart the apache2 service.

# /etc/init.d/apache2 restart

Now open the file in the browser ( Eg: http://yourip/info.php ) you can see the php information page as below.
Make sure you can see the mysql details in the php information page.

ubuntu phpinfo

We have successfully configured Apache2 , mysql and php.