The Perfect Server - Debian Wheezy (nginx, BIND, Dovecot, ISPConfig 3)

Version 1.0
Author: Falko Timme
Follow me on Twitter
Last edited 05/07/2013

This tutorial shows how to prepare a Debian Wheezy server (with nginx, BIND, Dovecot) for the installation of ISPConfig 3, and how to install ISPConfig 3. ISPConfig 3 is a webhosting control panel that allows you to configure the following services through a web browser: Apache or nginx web server, Postfix mail server, Courier or Dovecot IMAP/POP3 server, MySQL, BIND or MyDNS nameserver, PureFTPd, SpamAssassin, ClamAV, and many more. This setup covers nginx (instead of Apache), BIND (instead of MyDNS), and Dovecot (instead of Courier).

If you want to use nginx instead of Apache with ISPConfig, please note that your nginx version must be at least 0.8.21, and you must install PHP-FPM as well. For CGI/Perl support, you must use fcgiwrap. This is all covered by this tutorial.

Please note that you cannot use this tutorial for Debian Squeeze because Squeeze comes with an older nginx version (0.7.67.) and does not have a PHP-FPM package!

Please note that this setup does not work for ISPConfig 2! It is valid for ISPConfig 3 only!

I do not issue any guarantee that this will work for you!

 

1 Requirements

To install such a system you will need the following:

 

2 Preliminary Note

In this tutorial I use the hostname server1.example.com with the IP address 192.168.0.100 and the gateway 192.168.0.1. These settings might differ for you, so you have to replace them where appropriate.

 

3 The Base System

Insert your Debian Wheezy network installation CD into your system and boot from it. Select Install (this will start the text installer - if you prefer a graphical installer, select Graphical install):

Choose your language:

Then select your location:

If you've selected an uncommon combination of language and location (like English as the language and Germany as the location, as in my case), the installer might tell you that there is no locale defined for this combination; in this case you have to select the locale manually. I select en_US.UTF-8 here:

Choose a keyboard layout:

The installer checks the installation CD, your hardware, and configures the network with DHCP if there is a DHCP server in the network:

Enter the hostname. In this example, my system is called server1.example.com, so I enter server1:

Enter your domain name. In this example, this is example.com:

Afterwards, give the root user a password:

Confirm that password to avoid typos:

Create a normal user account, for example the user Administrator with the user name administrator (don't use the user name admin as it is a reserved name on Debian Wheezy):

Share this page:

25 Comment(s)

Add comment

Comments

From: Unit at: 2013-05-12 19:21:04

Hi,

thank you for the tutorial. I just installed nginx & ISPConfig on my server, but I get an 500 Internal Error after uploading wordpress files and the .sql database in mysql.

I also tried to delete .htaccess, but it didn't help. The 500 Error appears on index, but I have no problem to access the admin backend of wordpress at domain/wp-admin...

Can someone please tell me what could fix it? 

From: Kubek at: 2013-05-19 10:54:20

Check your error.log in log/ directory of your site.

From: at: 2013-08-27 10:51:45

Disable "Own Error-Documents"

From: Bulk sms gateway at: 2013-05-20 10:59:19

Thank you for posting this info.

From: meth at: 2013-08-15 18:07:05

If you want to use it using vagrant or install everything in your own server using puppet you can try https://github.com/meth/puppet-ispconfig/

All contributions are welcomed :) 

 

From: Bradley Gillap at: 2014-02-15 20:21:52

Why not munit in this guide? Is it apache only?

From: at: 2014-03-26 11:15:31

You should use  insserv -rf spamassassin instead of update-rc.d -f spamassassin remove

From: Arthur at: 2014-04-22 22:08:05

 Hello!

Why do I need to change the configuration for a static IP address? Why not suitable DHCP?

From: at: 2014-10-24 09:00:49

I have been setting a few of these as Proxmox OpenVZ VMs.

Before diving into this tutorial:

Basically, you start out by downloading the current Wheezy OpenVZ template (at the time of this writing that's 7.0.2) and creating an openVZ container. Once that is up and running and reachable from the outside world, you can come back to the perfect server tutorial.

Since your virtual machine is already up and running, you can skip over the installation/setup parts. I'm assuming if you're setting up a VM, you already know how to set up your network, and can assign an IP to the VM through venet. Setting all this up would be part of a proxmox tutorial, and goes beyond what makes sense here.

Basically, after skipping the installation steps of this manual, you start directly with step 7 ("Update Your Debian Installation"), and right after that, continue with:

7.a 

apt-get install console-data keyboard-configuration


This should bring up debconfig with a menu where you can configure your keyboard layout. Pick the keyboard layout you wish to use here.

7.b

dpkg-reconfigure locales

Here you choose which locales your system should use. The debian template seems to not set any default here. In my case, I choose both of these:

de_DE.UTF-8 
en_US.UTF-8

Personally, I then set de_DE.UTF-8 as my default locale (German). If you're from the US, you can of course simply not install this locale at all. If you're from the UK, you might prefer to install and select en_GB.UTF-8, etc. - use your common sense here.

7.c

dpkg-reconfigure tzdata

This is to configure your timezone. By default, your server will use UTC time. This may be fine for you. If not, you can choose a different timezone here (e.g. "Europe/Berlin" for a server in Germany).

You can now continue with step 8 of the perfect server tutorial.

From: Sam at: 2013-07-28 13:03:09

If you are getting an error message like this - it's because you are propably using some sort of apt-cacher software.

Failed to fetch http://ftp.de.debian.org/debian/pool/main/libm/libmail-sendmail-perl/libmail-sendmail-perl_0.79.16-1_all.deb  Size mismatch
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
 

Try without the apt-cacher conf file.

rm /etc/apt/apt.conf.d/90httpproxy

From: Anonymous at: 2013-11-12 16:43:07

in /etc/nginx/sites-enabled/000-apps.vhost I had to change location /images/mailman/ { alias /usr/share/images/mailman/; } to location ^~ /images/mailman/ { alias /usr/share/images/mailman/; } to display images on the mailman web interface properly. from http://wiki.nginx.org/HttpCoreModule#location location ^~ /images/ { # matches any query beginning with /images/ and halts searching, # so regular expressions will not be checked. [ configuration D ] }

From: Arthur at: 2014-04-23 17:18:24

 Where should I add this line?

usrjquota=quota.user,grpjquota=quota.group,jqfmt=vfsv0

 My config.

proc  /proc       proc    defaults    0    0
none  /dev/pts    devpts  rw,gid=5,mode=620    0    0
none  /run/shm    tmpfs   defaults    0    0


From: Danny at: 2014-06-06 15:34:43

All what you need to do is a reweite for the whole server/vhost  

server {
        listen       80;
        server_name  you.server.domain.net;
         rewrite ^/(.*)$ /phpmyadmin/$1;
         location /phpmyadmin {
                root /usr/share;
                index index.php index.html index.htm;
                location ~ ^/phpmyadmin/(.+\.php)$ {
                        try_files $uri =404;
                        root /usr/share/;
                        fastcgi_pass unix:/var/run/php5-fpm.sock;
                        fastcgi_index index.php;
                        fastcgi_param SCRIPT_FILENAME $request_filename;
                        include /etc/nginx/fastcgi_params;
                        fastcgi_param PATH_INFO $fastcgi_script_name;
                        fastcgi_buffer_size 128k;
                        fastcgi_buffers 256 4k;
                        fastcgi_busy_buffers_size 256k;
                        fastcgi_temp_file_write_size 256k;
                        fastcgi_intercept_errors on;
                }
                location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
                        root /usr/share;
                }
         }
         location /phpMyAdmin {
                rewrite ^/* /phpmyadmin last;
         }
    }

From: Raj at: 2014-08-29 11:59:21

Where do i add this?

kindly elaborate 

noob here

From: A Scott at: 2014-12-17 19:31:22

At the Jailkit install step, if you get errors like below:

make: dpkg-architecture: Command not found
make: dpkg-architecture: Command not found
dh_testdir
make: dh_testdir: Command not found
make: *** [config.status] Error 127

Run the following command to install dependancies.

apt-get install dpkg-dev debhelper

ALSO:

Jailkit is at version 2.17 as of December 2014, so do this instead of the jailkit step in the how-to:

cd /tmp
wget http://olivier.sessink.nl/jailkit/jailkit-2.17.tar.gz
tar xvfz jailkit-2.17.tar.gz
cd jailkit-2.17
./debian/rules binary

From: Saevar at: 2013-05-12 16:39:47

That would be so great if we could have this setup in .img format so it would be possible to dd this setup on HDD, keep up the good work, p.s. i would buy this setup :) 

From: guntbert at: 2013-05-30 16:13:43

The first link under Links should be Debian: http://www.debian.org/  :-))

From: x42 at: 2013-06-25 05:37:43

some libs moved to gnu. chroot doesn't work. edit /etc/jailkit/jk_init.ini

https://savannah.nongnu.org/bugs/index.php?38596 wrote:

[uidbasics]
# this section probably needs adjustment on 64bit systems
# or non-Linux systems
comment = common files for all jails that need user/group information
libraries = /lib/libnsl.so.1, /lib64/libnsl.so.1, /lib/libnss*.so.2, /lib64/libnss*.so.2, /lib/x86_64-linux-gnu/libnsl.so.1, /lib/x86_64-linux-gnu/libnss*.so.2
regularfiles = /etc/nsswitch.conf, /etc/ld.so.conf

[netbasics]
comment = common files for all jails that need any internet connectivity
libraries = /lib/libnss_dns.so.2, /lib64/libnss_dns.so.2, /lib/x86_64-linux-gnu/libnss_dns.so.2
regularfiles = /etc/resolv.conf, /etc/host.conf, /etc/hosts, /etc/protocols

From: at: 2013-07-23 22:11:20

Wordpress issue - just a note that once I installed WordPress I could browse to the home page fine but all other pages gave me Error 500.



Thanks, Matt

From: Mindbuild at: 2014-05-09 10:28:58

Thanks for the excellent tutorial. Everything worked really well.

After installing ispconfig and using the above code to configure squirrelmail with Nginx, I was unable to send email. I got the error 404 not found. 

I had to replace the above code (non https) with this:

location /squirrelmail {
       root /usr/share/;
       index index.php index.html index.htm;
       location ~ ^/squirrelmail/(.+\.php)$ {
               try_files $uri =404;
               root /usr/share/;
               include /etc/nginx/fastcgi_params;
               # To access SquirrelMail, the default user (like www-data on Debian/Ubuntu) must be used
               fastcgi_pass 127.0.0.1:9000;
               fastcgi_index index.php;
               fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
               fastcgi_buffer_size 128k;
               fastcgi_buffers 256 4k;
               fastcgi_busy_buffers_size 256k;
               fastcgi_temp_file_write_size 256k;
       }
       location ~* ^/squirrelmail/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
               root /usr/share/;
       }
}
location /webmail {
       rewrite ^/* /squirrelmail last;
}

 found here: http://www.howtoforge.com/forums/showthread.php?t=55342

After that I had  no problem in sending emails.

 

From: Florian at: 2014-09-16 18:55:55

Excellent work! Everything writen here works out of the box! This is a precious save of time! 

From: Idso at: 2014-12-05 19:42:30

Thanks for the excellent tutorial !! I just set it up on a testserver, but I should have no problem doing this on a production server thanks to this guide.

From: sidbyron at: 2015-01-25 02:19:34

Hi,

This is the correct code for NGINX directives in Debian and ISPConfig.

First this is the code for http access without SSL:

 

#Configuration of phpMyAdmin

location /phpmyadmin/ {

   root /var/www/apps;               

   index index.php index.html index.htm;

     location ~ ^/(.+\.php)$ {

try_files $uri =404;                       

root /var/www/apps;

fastcgi_pass unix:/var/run/php5-fpm.sock;

fastcgi_index index.php;

        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include /etc/nginx/fastcgi_params;

fastcgi_buffer_size 128k;

fastcgi_buffers 256 4k;

fastcgi_busy_buffers_size 256k;

fastcgi_temp_file_write_size 256k;

fastcgi_intercept_errors on;

      }

      location ~* ^/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {

 root /var/www/apps;

      }

 

}

location /phpMyAdmin {

   rewrite ^/* /phpmyadmin last;

}

 

#Finish configuration of phpMyAdmin

 

Second This is for phpmyadmin with SSL certificate:

 

#Configuration de phpMyAdmin

location /phpmyadmin/ {

   root /var/www/apps;               

   index index.php index.html index.htm;

     location ~ ^/(.+\.php)$ {

try_files $uri =404;                       

root /var/www/apps;

fastcgi_pass unix:/var/run/php5-fpm.sock;

        fastcgi_param HTTPS $https; # <-- add this line

fastcgi_index index.php;

        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include /etc/nginx/fastcgi_params;

fastcgi_buffer_size 128k;

fastcgi_buffers 256 4k;

fastcgi_busy_buffers_size 256k;

fastcgi_temp_file_write_size 256k;

fastcgi_intercept_errors on;

      }

      location ~* ^/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {

 root /var/www/apps;

      }

      location ~* ^/{

          if ($scheme = http) {

   return 301 https://$server_name$request_uri;

 }

      }

 

}

location /phpMyAdmin {

   rewrite ^/* /phpmyadmin last;

}

 

#Finish Configuration phpMyAdmin

This configuration is for people that setup the phpmyadmin on directory /var/www/apps and want to get load for each site without create a new site.

Kind Regards.

From: newtesla at: 2015-03-09 19:44:07

Please, abandon ntpdate in future: it has already created problems.

From: Muhamad Abdulkadir at: 2015-04-08 21:51:54

Perfect tutorial, except that I found "502 Bad Gateway" when I opened http://server1.example.com:8081/webmail 

To solve this problem, do this:

vi /etc/php5/fpm/pool.d/www.conf

and then change: 

; listen.owner = www-data; listen.group = www-data

to: 

listen.owner = www-datalisten.group = www-data