The Perfect Server - Debian 8.4 Jessie (Apache2, BIND, Dovecot, ISPConfig 3.1) - Page 2

10 Install Apache2, PHP, FCGI, suExec, Pear, phpMyAdmin, and mcrypt

Apache2, PHP5, phpMyAdmin, FCGI, suExec, Pear, and mcrypt can be installed as follows:

apt-get install apache2 apache2.2-common apache2-doc apache2-mpm-prefork apache2-utils libexpat1 ssl-cert libapache2-mod-php5 php5 php5-common php5-gd php5-mysql php5-imap phpmyadmin php5-cli php5-cgi libapache2-mod-fcgid apache2-suexec php-pear php-auth php5-mcrypt mcrypt php5-imagick imagemagick libruby libapache2-mod-python php5-curl php5-intl php5-memcache php5-memcached php5-pspell php5-recode php5-sqlite php5-tidy php5-xmlrpc php5-xsl memcached libapache2-mod-passenger

You will see the following questions:

Web server to reconfigure automatically: <- apache2
Configure database for phpmyadmin with dbconfig-common? <- yes
Enter the password of the administrative user? <- yourrootmysqlpassword
Enter the phpmyadmin application password? <-  Just press enter

Then run the following command to enable the Apache modules suexec, rewrite, ssl, actions, and include (plus dav, dav_fs, and auth_digest if you want to use WebDAV):

a2enmod suexec rewrite ssl actions include dav_fs dav auth_digest cgi headers

To ensure that the server can not be attacked trough the HTTPOXY vulnerability, we will disable the HTTP_PROXY header in apache globally by adding the configuration file /etc/apache2/conf-available/httpoxy.conf.

sudo nano /etc/apache2/conf-available/httpoxy.conf

Paste the following content to the file:

<IfModule mod_headers.c>
    RequestHeader unset Proxy early

And enable the module by running:

a2enconf httpoxy
service apache2 restart

10.1 Install HHVM (HipHop Virtual Machine)

In this step we will install HHVM from its official Debian repository. Add the HHVM repo and import the key.

sudo apt-key adv --recv-keys --keyserver hkp:// 0x5a16e7281be7a449
echo deb jessie main | sudo tee /etc/apt/sources.list.d/hhvm.list

Update the package list:

sudo apt-get update

and install HHVM:

sudo apt-get install hhvm

SuPHP is not available anymore for Debian Jessie. The suphp mode should not be used anymore in ISPConfig as there are better PHP modes like php-fpm and php-fcgi available. If you really need suphp for legacy reasons, then follow the steps in this chapter to compile it manually. But we do not recommend its installation.

apt-get install apache2-dev build-essential autoconf automake libtool flex bison debhelper binutils

cd /usr/local/src
tar zxvf suphp-0.7.2.tar.gz
wget -O suphp.patch
patch -Np1 -d suphp-0.7.2 < suphp.patch
cd suphp-0.7.2
autoreconf -if
./configure --prefix=/usr/ --sysconfdir=/etc/suphp/ --with-apr=/usr/bin/apr-1-config --with-apache-user=www-data --with-setid-mode=owner --with-logfile=/var/log/suphp/suphp.log
make install

Create the suphp configuration directory and suphp.conf file:

mkdir /var/log/suphp
mkdir /etc/suphp
nano /etc/suphp/suphp.conf

;Path to logfile


;User Apache is running as

;Path all scripts have to be in

;Path to chroot() to before executing script

; Security options

;Check wheter script is within DOCUMENT_ROOT

;Send minor error messages to browser

;PATH environment variable

;Umask to set, specify in octal notation

; Minimum UID

; Minimum GID

;Handler for php-scripts

;Handler for CGI-scripts

Next we will add a config file to load the suphp module in apache:

echo "LoadModule suphp_module /usr/lib/apache2/modules/" > /etc/apache2/mods-available/suphp.load

And then open /etc/apache2/mods-available/suphp.conf...

nano /etc/apache2/mods-available/suphp.conf

... and add the following content:

<IfModule mod_suphp.c>
        AddType application/x-httpd-suphp .php .php3 .php4 .php5 .phtml
        suPHP_AddHandler application/x-httpd-suphp

    <Directory />
        suPHP_Engine on

    # By default, disable suPHP for debian packaged web applications as files
    # are owned by root and cannot be executed by suPHP because of min_uid.
    <Directory /usr/share>
        suPHP_Engine off

# # Use a specific php config file (a dir which contains a php.ini file)
#       suPHP_ConfigPath /etc/php5/cgi/suphp/
# # Tells mod_suphp NOT to handle requests with the type <mime-type>.
#       suPHP_RemoveHandler <mime-type>

Enable the suphp module in apache:

a2enmod suphp

Restart Apache afterwards:

service apache2 restart

11 Install Let's Encrypt

ISPConfig 3.1  has support for the free SSL Certificate authority Let's encrypt. The Let's Encrypt function allows you to create free SSL certificates for your website from within ISPConfig.

Now we will add support for Let's encrypt.

mkdir /opt/certbot
cd /opt/certbot
chmod a+x ./certbot-auto

Now run the certboot-auto command which will download and install the software and it's dependencies.


The command will then tell you that "no names were found in your configuration files" and asks if it shall continue, please chose "no" here as the certs will be created by ISPConfig.

12 Install PHP-FPM and XCache

XCache is a free and open PHP opcode cacher for caching and optimizing PHP intermediate code. It's similar to other PHP opcode cachers, such as eAccelerator and APC. It is strongly recommended to have one of these installed to speed up your PHP page.

Starting with ISPConfig 3.0.5, there is an additional PHP mode that you can select for usage with Apache: PHP-FPM.

To use PHP-FPM with Apache, we need the mod_fastcgi Apache module (please don't mix this up with mod_fcgid - they are very similar, but you cannot use PHP-FPM with mod_fcgid). We can install PHP-FPM and mod_fastcgi as follows:

apt-get install libapache2-mod-fastcgi php5-fpm

Make sure you enable the module and restart Apache:

a2enmod actions fastcgi alias
service apache2 restart

12.2 Install XCache

XCache can be installed as follows:

apt-get install php5-xcache

Now restart Apache:

service apache2 restart


13 Install Mailman

ISPConfig allows you to manage (create/modify/delete) Mailman mailing lists. If you want to make use of this feature, install Mailman as follows:

apt-get install mailman

Select at least one language, e.g.:

Languages to support: <-- en (English)
Missing site list <-- Ok

Before we can start Mailman, a first mailing list called mailman must be created:

newlist mailman

root@server1:~# newlist mailman
Enter the email of the person running the list: <-- admin email address, e.g.
Initial mailman password: <-- admin password for the mailman list
To finish creating your mailing list, you must edit your /etc/aliases (or
equivalent) file by adding the following lines, and possibly running the
`newaliases' program:

## mailman mailing list
mailman:              "|/var/lib/mailman/mail/mailman post mailman"
mailman-admin:        "|/var/lib/mailman/mail/mailman admin mailman"
mailman-bounces:      "|/var/lib/mailman/mail/mailman bounces mailman"
mailman-confirm:      "|/var/lib/mailman/mail/mailman confirm mailman"
mailman-join:         "|/var/lib/mailman/mail/mailman join mailman"
mailman-leave:        "|/var/lib/mailman/mail/mailman leave mailman"
mailman-owner:        "|/var/lib/mailman/mail/mailman owner mailman"
mailman-request:      "|/var/lib/mailman/mail/mailman request mailman"
mailman-subscribe:    "|/var/lib/mailman/mail/mailman subscribe mailman"
mailman-unsubscribe:  "|/var/lib/mailman/mail/mailman unsubscribe mailman"

Hit enter to notify mailman owner... <-- ENTER


Open /etc/aliases afterwards...

nano /etc/aliases

... and add the following lines:

## mailman mailing list
mailman:              "|/var/lib/mailman/mail/mailman post mailman"
mailman-admin:        "|/var/lib/mailman/mail/mailman admin mailman"
mailman-bounces:      "|/var/lib/mailman/mail/mailman bounces mailman"
mailman-confirm:      "|/var/lib/mailman/mail/mailman confirm mailman"
mailman-join:         "|/var/lib/mailman/mail/mailman join mailman"
mailman-leave:        "|/var/lib/mailman/mail/mailman leave mailman"
mailman-owner:        "|/var/lib/mailman/mail/mailman owner mailman"
mailman-request:      "|/var/lib/mailman/mail/mailman request mailman"
mailman-subscribe:    "|/var/lib/mailman/mail/mailman subscribe mailman"
mailman-unsubscribe:  "|/var/lib/mailman/mail/mailman unsubscribe mailman"



and restart Postfix:

service postfix restart

Finally, we must enable the Mailman Apache configuration:

ln -s /etc/mailman/apache.conf /etc/apache2/conf-enabled/mailman.conf

This defines the alias /cgi-bin/mailman/ for all Apache vhosts, which means you can access the Mailman admin interface for a list at, and the web page for users of a mailing list can be found at

Under you can find the mailing list archives.

Restart Apache afterwards:

service apache2 restart

Then start the Mailman daemon:

service mailman start


14 Install PureFTPd and Quota

PureFTPd and quota can be installed with the following command:

apt-get install pure-ftpd-common pure-ftpd-mysql quota quotatool

Edit the file /etc/default/pure-ftpd-common...

nano /etc/default/pure-ftpd-common

... and make sure that the start mode is set to standalone and set VIRTUALCHROOT=true:


Now we configure PureFTPd to allow FTP and TLS sessions. FTP is a very insecure protocol because all passwords and all data are transferred in clear text. By using TLS, the whole communication can be encrypted, thus making FTP much more secure.

If you want to allow FTP and TLS sessions, run

echo 1 > /etc/pure-ftpd/conf/TLS

In order to use TLS, we must create an SSL certificate. I create it in /etc/ssl/private/, therefore I create that directory first:

mkdir -p /etc/ssl/private/

Afterwards, we can generate the SSL certificate as follows:

openssl req -x509 -nodes -days 7300 -newkey rsa:2048 -keyout /etc/ssl/private/pure-ftpd.pem -out /etc/ssl/private/pure-ftpd.pem

Country Name (2 letter code) [AU]: <-- Enter your Country Name (e.g., "DE").
State or Province Name (full name) [Some-State]: <-- Enter your State or Province Name.
Locality Name (eg, city) []: <-- Enter your City.
Organization Name (eg, company) [Internet Widgits Pty Ltd]: <-- Enter your Organization Name (e.g., the name of your company).
Organizational Unit Name (eg, section) []: <-- Enter your Organizational Unit Name (e.g. "IT Department").
Common Name (eg, YOUR name) []: <-- Enter the Fully Qualified Domain Name of the system (e.g. "").
Email Address []: <-- Enter your Email Address.

Change the permissions of the SSL certificate:

chmod 600 /etc/ssl/private/pure-ftpd.pem

Then restart PureFTPd:

service pure-ftpd-mysql restart

Edit /etc/fstab. Mine looks like this (I added ,usrjquota=quota.user,,jqfmt=vfsv0 to the partition with the mount point /):

nano /etc/fstab

# /etc/fstab: static file system information.
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda1 during installation
UUID=3dc3b58d-97e5-497b-8254-a913fdfc5408 / ext4 errors=remount-ro,usrjquota=quota.user,,jqfmt=vfsv0 0 1
# swap was on /dev/sda5 during installation
UUID=36bf486e-8f76-492d-89af-5a8eb3ce8a02 none swap sw 0 0
/dev/sr0 /media/cdrom0 udf,iso9660 user,noauto 0 0

To enable quota, run these commands:

mount -o remount /

quotacheck -avugm
quotaon -avug


15 Install BIND DNS Server

BIND can be installed as follows:

apt-get install bind9 dnsutils

 If yor server is a virtual machine, then it is highly recommended to install the haveged daemon to get a higher entropy for DNSSEC signing. You can install haveged on non virtual servers as well, it should not hurt.

apt-get install haveged

An explanation on that topic can be found here.

16 Install Webalizer and AWStats

Webalizer and AWStats can be installed as follows:

apt-get install webalizer awstats geoip-database libclass-dbi-mysql-perl libtimedate-perl

Open /etc/cron.d/awstats afterwards...

nano /etc/cron.d/awstats

... and comment out everything in that file:


#*/10 * * * * www-data [ -x /usr/share/awstats/tools/ ] && /usr/share/awstats/tools/

# Generate static reports:
#10 03 * * * www-data [ -x /usr/share/awstats/tools/ ] && /usr/share/awstats/tools/


17 Install Jailkit

Jailkit is needed only if you want to chroot SSH users. It can be installed as follows (important: Jailkit must be installed before ISPConfig - it cannot be installed afterwards!):

apt-get install build-essential autoconf automake libtool flex bison debhelper binutils

cd /tmp
tar xvfz jailkit-2.19.tar.gz
cd jailkit-2.19
./debian/rules binary

You can now install the Jailkit .deb package as follows:

cd ..
dpkg -i jailkit_2.19-1_*.deb
rm -rf jailkit-2.19*


18 Install fail2ban and UFW Firewall

This is optional but recommended, because the ISPConfig monitor tries to show the log:

apt-get install fail2ban

To make fail2ban monitor PureFTPd and Dovecot, create the file /etc/fail2ban/jail.local:

nano /etc/fail2ban/jail.local


enabled  = true
port     = ftp
filter   = pureftpd
logpath  = /var/log/syslog
maxretry = 3

enabled = true
filter = dovecot-pop3imap
action = iptables-multiport[name=dovecot-pop3imap, port="pop3,pop3s,imap,imaps", protocol=tcp]
logpath = /var/log/mail.log
maxretry = 5

enabled  = true
port     = smtp
filter   = postfix-sasl
logpath  = /var/log/mail.log
maxretry = 3

Then create the following two filter files:

nano /etc/fail2ban/filter.d/pureftpd.conf

failregex = .*pure-ftpd: \(.*@<HOST>\) \[WARNING\] Authentication failed for user.*
ignoreregex =

nano /etc/fail2ban/filter.d/dovecot-pop3imap.conf

failregex = (?: pop3-login|imap-login): .*(?:Authentication failure|Aborted login \(auth failed|Aborted login \(tried to use disabled|Disconnected \(auth failed|Aborted login \(\d+ authentication attempts).*rip=(?P<host>\S*),.*
ignoreregex =

Then, to add the ignoreregex line in the postfix-sasl filter file, run:

echo "ignoreregex =" >> /etc/fail2ban/filter.d/postfix-sasl.conf

Restart fail2ban afterwards:

service fail2ban restart

To install the UFW firewall, run this apt command:

apt-get install ufw

Share this page:

Suggested articles

12 Comment(s)

Add comment


From: webhunter at: 2016-06-11 22:54:33

>> Insatll PHP-FPM and xCache:

Package libapache2-mod-fastcgi is not available, but is referred to by another package.This may mean that the package is missing, has been obsoleted, or is only available from another source

E: Package 'libapache2-mod-fastcgi' has no installation candidate


From: till at: 2016-06-12 15:40:19

You missed to configure the /etc/apt/sources.list file as described in chapter 5. Go back to chapter 5, configure the sources.list as described there, run "apt-get update" and then rerun the command to install the apache module.

From: rmontagud at: 2016-07-18 13:49:11

You can replace the cerbot installation with a package from backports which is the recommended install option for debian as of today ( )

From: David Bucknell at: 2017-02-26 19:43:50

I get this after editing /etc/fstab (every time) because I use a virtual hosting service. 

"quotacheck: Cannot stat() mounted device /dev/root: No such file or directory"

So, I have to put in a symbolic link, in my case like this:

ln -s /dev/sda /dev/root

Then, to make sure the link is not lost upon rebooting:

ln -s /dev/xvda /dev/root

In my humble opinion, it would be really nice if a noteabout this were included in your instructions, with which I don't have any other problems (don't a lot of people use virtual servers now?):

Otherwise, since I don't install a new server every day, I have to search -- and it's only in comments on _old_ versions of this how-to. 

Just my 2 cents.


Thank you for this extremely helpful resource!

From: orfi at: 2017-06-04 09:26:47

install suphp 


from where we get the patch ?

wget -O suphp.patch 

From: alfredo.ardito at: 2017-06-06 21:44:06

Error Installing hhvm.

I did a clean install from Debian 8.8 and followed this tutorial step by step. When I tried to install hhvm I got this error:

Some packages could not be installed. This may mean that you haverequested an impossible situation or if you are using the unstabledistribution that some required packages have not yet been createdor been moved out of Incoming.The following information may help to resolve the situation:The following packages have unmet dependencies: hhvm : Depends: libsodium but it is not installableE: Unable to correct problems, you have held broken packages.

A few days ago I did the same installation successfully without errors. HHVM was also installed well without errors.I assume this happened with some latest debian upgrade. Does anyone have a clue what this is? Any workaround? 

From: till at: 2017-06-07 09:05:26

Normally Debian does not do such changes within a stable release. Please compare the /etc/apt/sources.list file of your server with the one of the working server or the one of this tutorial. Maybe there are some differences so that not all packages are available.

From: alfredo.ardito at: 2017-06-07 10:52:10

I check  /etc/apt/sources.list scrupulously and it's configured exactly as suggested in this tutorial. I'll try a new clean install using Debian 8.8 and follow all the steps described in this tutorial and I'll let you know.

From: alfredo.ardito at: 2017-06-08 16:33:32

I reinstalled Debian and ISPConfig again and it worked. Probably I had a temporary Internet outage. hhvm has been installed correctly without issues.

Thank you for the support. Regards AA

From: DirtyTodd at: 2017-07-17 09:15:22

I am on debian 8.8 and facing 2 errors

1. There is problem while installing XMPP unable to execute below cmd

[code]cd /opt; git clone metronome

cd ./metronome; ./configure --ostype=debian --prefix=/usrmakemake install




2. unable to perfectly execute installation of PureFTPd

what text to add and where to add after runing 

nano /etc/fstab

and also unable to execute

quotacheck -avugm quotaon -avug


From: till at: 2017-07-17 09:23:24

Please make a post in the forum to get help and include the exact error messages that you get in that post.

From: DirtyTodd at: 2017-07-17 13:06:53

Having Problem Executing Below Portion what diffrence will it make


Edit /etc/fstab. Mine looks like this (I added ,usrjquota=quota.user,,jqfmt=vfsv0 to the partition with the mount point /):

nano /etc/fstab

# /etc/fstab: static file system information.## Use 'blkid' to print the universally unique identifier for a# device; this may be used with UUID= as a more robust way to name devices# that works even if disks are added and removed. See fstab(5).## <file system> <mount point> <type> <options> <dump> <pass># / was on /dev/sda1 during installationUUID=3dc3b58d-97e5-497b-8254-a913fdfc5408 / ext4 errors=remount-ro,usrjquota=quota.user,,jqfmt=vfsv0 0 1# swap was on /dev/sda5 during installationUUID=36bf486e-8f76-492d-89af-5a8eb3ce8a02 none swap sw 0 0/dev/sr0 /media/cdrom0 udf,iso9660 user,noauto 0 0

To enable quota, run these commands:

mount -o remount /

quotacheck -avugmquotaon -avug