The Perfect Server - Debian Lenny (Debian 5.0) [ISPConfig 2]

Version 1.0
Author: Falko Timme
Last edited 02/16/2009

This tutorial shows how to set up a Debian Lenny (Debian 5.0) server that offers all services needed by ISPs and hosters: Apache web server (SSL-capable), Postfix mail server with SMTP-AUTH and TLS, BIND DNS server, Proftpd FTP server, MySQL server, Courier POP3/IMAP, Quota, Firewall, etc. In the end you should have a system that works reliably, and if you like you can install the free webhosting control panel ISPConfig 2 (i.e., ISPConfig runs on it out of the box).

I will use the following software:

  • Web Server: Apache 2.2.9 with PHP 5.2.6, Python, and Ruby
  • Database Server: MySQL 5.0.51a
  • Mail Server: Postfix
  • DNS Server: BIND9
  • FTP Server: proftpd
  • POP3/IMAP: I will use Maildir format and therefore install Courier-POP3/Courier-IMAP.
  • Webalizer for web site statistics

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

I want to say first that this is not the only way of setting up such a system. There are many ways of achieving this goal but this is the way I take. 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 Lenny network installtion 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:

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:

Now you have to partition your hard disk. For simplicity's sake I will create one big partition (with the mount point /) and a little swap partition so I select Guided - use entire disk (of course, the partitioning is totally up to you - if you like, you can create more than just one big partition, and you can also use LVM):

Select the disk that you want to partition:

Then select the partitioning scheme. As mentioned before, I select All files in one partition (recommended for new users) for simplicity's sake - it's up to your likings what you choose here:

When you're finished, select Finish partitioning and write changes to disk:

Select Yes when you're asked Write changes to disks?:

Share this page:

25 Comment(s)

Add comment

Comments

From: Tony at: 2009-03-14 06:40:55

As usual, fantastic guide by Falko!
However, chose the extra partitions - /var, /tmp, /usr & /home
Got all the way to end of this guide, went to install ISPConfig & got this error from the installer package -

ERROR: Sie benötigen mind. 512MB Platz im /root-Verzeichnis, um ISPConfig zu installieren! / You need at least 512MB of disk space in the /root directory to install ISPConfig!

Therefore it seems you must be careful when partitioning if using ISPConfig 2. ISPConfig 3 had no problem with same partitioning.

From: Anonymous at: 2009-02-20 22:24:52

From Etch onward, it is recommended that users use aptitude instead of apt-get.  Aptitude has advanced dependency handling that can avoid some serious problems in unusual situations. 

From the official debian documentation http://www.debian.org/releases/stable/i386/release-notes/ch-whats-new.en.html#s-pkgmgmt:

" The preferred program for package management from the command line is aptitude, which can perform the same package management functions as apt-get and has proven to be better at dependency resolution."

From: ree at: 2009-12-31 12:38:38

hi,

plz edit /etc/init.d/bind9 startup script!! 

to do it follow :

nano /etc/init.d/bind9

then find the PIDFILE def. and edit to look lile that:

PIDFILE=/var/lib/named/var/run/bind/run/named.pid

and restart bind9: 

/etc/init.d/bind9 restart

regards

From: Yves at: 2010-01-29 22:26:31

This is not necessary. The correct path inside the jail is /var/run/bind/run/named.pid

From: Yves at: 2010-01-31 13:11:58

To use IPv6, i.e. listen-on-v6, you need to mount proc inside your chroot:

 mkdir /var/lib/named/proc

 mount -t proc proc /var/lib/named/proc

 Don't forget to create a mount that persists after next reboot, i.e. by adding it to /etc/fstab

From: ROk at: 2010-03-18 09:50:34

In file /etc/network/interfaces DO NOT WRITE DNS adressess. ONLY /etc/resolv.conf

If you will need to specify your DNS servers manually in /etc/resolv.conf, which should look something like this:

search mydomain.example

nameserver 192.168.0.1

nameserver 4.2.2.2

Else this will be mistakes.

From: Nokao at: 2010-05-20 21:37:10

Do you think that the DNS step is important even for who don't need a DNS server ?

 

I mean ... is it true that a DNS server only for local software is "a must have" ?

From: Dima at: 2011-06-14 22:49:32

There is no need to manualy create aquota.user and aquota.group files. They are created automatically by using command quotacheck with appropriate keys ( -c -u -g )

From: at: 2009-05-07 18:19:57

I would suggest to setup addional parameters:

 

postconf -e 'smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_invalid_hostname,reject_non_fqdn_hostname,reject_non_fqdn_sender,
reject_non_fqdn_recipient,reject_unknown_sender_domain,reject_unknown_recipient_domain,reject_unauth_pipelining,reject_rbl_client dnsbl.njabl.org,
reject_rbl_client sbl-xbl.spamhaus.org,reject_rbl_client pbl.spamhaus.org,reject_rbl_client bl.spamcop.net,reject_rbl_client duinv.aupads.org,
reject_rbl_client ix.dnsbl.manitu.net,reject_rhsbl_sender rhsbl.sorbs.net,reject_unauth_destination'

postconf -e 'smtpd_sender_restrictions = permit_mynetworks,permit_sasl_authenticated, reject_rhsbl_sender dsn.rfc-ignorant.org'

From: Yves at: 2010-02-04 16:21:54

reject_unauth_destination is way to far to the end; it should be before the rbl calls...

reject_unauth_pipelining should be placed under smtpd_data_restrictions for Postfix 2.x!

From: Jerry at: 2010-08-18 19:44:38

I discovered in my /var/log/mail.log file that the aliases db hadn't yet been created.

I recommend that the reader be instructed to execute the # newaliases command before trying to # telnet localhost 25

 The aliases db wasn't there, in my case, because the system had just been installed and no other mail related foo had been done.

 cheers.

From: Jerry at: 2010-08-20 06:48:35

My experiments with the SMTPD showed that with the setup you recommend the relay wasn't "open"  i.e. it at least required a valid user name and password.  But what's the point of a password if it's sent in the clear??  You should strongly recommend that the
smtpd_tls_auth_only keyword be set to "Yes" to require that the client use the TLS feature when sending the password.

Also, I found that setting MECHANISMS to shadow  (for my tiny server) got me away from depending on /etc/courier/userdb.dat;  I now use the systems shadow password file. That minimizes my management overhead. I'm supposed to be productive at the job I trained for, not spending all my time being a sysadmin. :-)

j

From: Edgar at: 2010-10-31 21:45:59

correct this error:

postconf -e 'smtpd_tls_CAfile = /etc/postfix/ssl/cacert.pem'
instead of

postconf -e 'smtpd_tls CAfile = /etc/postfix/ssl/cacert.pem'

 

Awesome article

From: Edgar at: 2010-10-31 21:48:46

never mind my last comment. it was the stupid HIGHLIGHT that was hiding the '_'

 

 

From: at: 2009-05-07 18:22:13

To secure php you should edit

 

/etc/php5/apache2/php.ini

 

edit this line:

 

disable_functions = exec,system,passthru,shell_exec,popen,escapeshellcmd,proc_open,proc_nice,ini_restore

From: Emil at: 2009-05-07 10:13:57

i have sucessfully install ispconfig2, but how to change home directory for user example /home/username/public_html/ in ispconfig.

and i have recompile apache with suexec in /home

please advise

thanks

 

 

From: Sanjay K at: 2009-04-18 00:30:49

The tutorial is great.

I did have a few glitches along the way, much of which was due to php5-idn not being installed properly. Eventually I decided not to install it. (Don't know if that would cause other problems down the line). 

I also found aptitude to be marginally better than apt-get especially aptitude purge as a great help to uninstall the failing packages.

And I am absolutely delighted to see the ISPConfig screen. Thanks a lot Falko!

Regards

Sanjay

 

From: light-blue at: 2009-04-01 04:42:57

So that you don't spend 14 hours confused and frustrated like me, be sure that you are NOT submitting forms with lots of data (e.g. 100 form items--yes, I know they're huge by design) when using this setup. Suhosin won't allow that, and submits may FAIL SILENTLY.

after playing with standard php.ini POST settings for WAY too long, /var/log/apache2/error.log was the clue that solved this problem...

ALERT - configured POST variable limit exceeded - dropped variable 'field_agreement[0][value]' (attacker '192.168.10.13', file '/var/www/drupal/index.php'), referer: https://server.mycompany.com/node/add/agreement

The solution is simple ...

#vi /etc/php5/conf.d/suhosin.ini

set these values:

suhosin.post.max_vars = 1000

suhosin.request.max_vars = 1000

From: Anonymous at: 2009-02-20 23:29:32

Is there some reason why you've chosen Courier and not Dovecot for the IMAP server?

From: Pat Foley at: 2009-03-04 22:01:00

Falko. Thanks for all the tutorials! When creating the server (www) behind a router, is it still necessary to use a real tld when ispconfig is going to be added?

From: Leslie at: 2009-06-11 20:11:29

Hi all!

I am starter in perfect server configuration... even server configuration...but with this wonderful manual I did the impossible... :-)

Thanks Falko !

But this is not the end:

ISP is runninig I logged in and changed the login name from admin to other and the password and started to study ISP, and then logged out...

Now I can't log in with my new user name and password, I get the error code: 1002 or 1004

 Please help

From: Anonymous at: 2009-10-03 05:00:43

How do I change the domain.tld from .com to .net!?!?!?! LoL... The setup was PERFECT. Just had to change the ISPConfig to reflect 5.0.3 but other than that, this server is running and working! I just need to change the domain TLD from .com to .net for obvious reasons... Thanks in Advance for your assistance... I tried to change it in hosts and apache wouldnt restart... I need to change ALL instances BTW, from Start to Finish... Im pretty savvy, but this is above me ATM and Im not finding everything I need via google searches. Again Thank You in Advance for your Help. Mike

From: at: 2010-02-17 21:05:09

Falko,

 This How-To is on point; however, I do have a question.  How secure is this setup as it is described here?  By following all of these steps, we are opening a lot of ports on the server and I believe it opens us up to a lot of liability.  Anyone have any pointers or suggestions?  Am I being overly paranoid?  Any input would be appreciated. 

 KaBarsEdge

From: Bernard at: 2010-02-27 13:47:40

To enable usage of FTP username of an admin user for particular ISPConfig domain you have to disable ProFTP check for valid shell (as /dev/null isn't and this one gets added to ISPConfig users with disabled shell access). You have to uncomment this to /etc/proftpd/proftpd.conf :

[...]
 RequireValidShell           off
[...]

From: metoo at: 2010-07-21 20:50:59

thanks for great howto

i have choose (server1) as my host name as described in the tuto.

but when i nstall ispconfig 2 it tell :

Please enter the host name: E.g. www

what to write  in this case ? www or server1 ?

thanks