The Perfect Server - Ubuntu 12.04 LTS (nginx, BIND, Dovecot, ISPConfig 3) - Page 3

4 Get root Privileges

After the reboot you can login with your previously created username (e.g. administrator). Because we must run all the steps from this tutorial with root privileges, we can either prepend all commands in this tutorial with the string sudo, or we become root right now by typing

sudo su

(You can as well enable the root login by running

sudo passwd root

and giving root a password. You can then directly log in as root, but this is frowned upon by the Ubuntu developers and community for various reasons. See http://ubuntuforums.org/showthread.php?t=765414.)

 

5 Install The SSH Server (Optional)

If you did not install the OpenSSH server during the system installation, you can do it now:

apt-get install ssh openssh-server

From now on you can use an SSH client such as PuTTY and connect from your workstation to your Ubuntu 12.04 server and follow the remaining steps from this tutorial.

 

6 Install vim-nox (Optional)

I'll use vi as my text editor in this tutorial. The default vi program has some strange behaviour on Ubuntu and Debian; to fix this, we install vim-nox:

apt-get install vim-nox

(You don't have to do this if you use a different text editor such as joe or nano.)

 

7 Configure The Network

Because the Ubuntu installer has configured our system to get its network settings via DHCP, we have to change that now because a server should have a static IP address. Edit /etc/network/interfaces and adjust it to your needs (in this example setup I will use the IP address 192.168.0.100 and the DNS servers 8.8.8.8 and 8.8.4.4 - starting with Ubuntu 12.04, you cannot edit /etc/resolv.conf directly anymore, but have to specify your nameservers in your network configuration - see

man resolvconf

for more details):

vi /etc/network/interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
        address 192.168.0.100
        netmask 255.255.255.0
        network 192.168.0.0
        broadcast 192.168.0.255
        gateway 192.168.0.1
        dns-nameservers 8.8.8.8 8.8.4.4

Then restart your network:

/etc/init.d/networking restart

Then edit /etc/hosts. Make it look like this:

vi /etc/hosts

127.0.0.1       localhost.localdomain   localhost
192.168.0.100   server1.example.com     server1

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

Now run

echo server1.example.com > /etc/hostname
/etc/init.d/hostname restart

Afterwards, run

hostname
hostname -f

Both should show server1.example.com now.

 

8 Edit /etc/apt/sources.list And Update Your Linux Installation

Edit /etc/apt/sources.list. Comment out or remove the installation CD from the file and make sure that the universe and multiverse repositories are enabled. It should look like this:

vi /etc/apt/sources.list

#

# deb cdrom:[Ubuntu-Server 12.04 LTS _Precise Pangolin_ - Release amd64 (20120424.1)]/ dists/precise/main/binary-i386/
# deb cdrom:[Ubuntu-Server 12.04 LTS _Precise Pangolin_ - Release amd64 (20120424.1)]/ dists/precise/restricted/binary-i386/
# deb cdrom:[Ubuntu-Server 12.04 LTS _Precise Pangolin_ - Release amd64 (20120424.1)]/ precise main restricted

#deb cdrom:[Ubuntu-Server 12.04 LTS _Precise Pangolin_ - Release amd64 (20120424.1)]/ dists/precise/main/binary-i386/
#deb cdrom:[Ubuntu-Server 12.04 LTS _Precise Pangolin_ - Release amd64 (20120424.1)]/ dists/precise/restricted/binary-i386/
#deb cdrom:[Ubuntu-Server 12.04 LTS _Precise Pangolin_ - Release amd64 (20120424.1)]/ precise main restricted

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://de.archive.ubuntu.com/ubuntu/ precise main restricted
deb-src http://de.archive.ubuntu.com/ubuntu/ precise main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://de.archive.ubuntu.com/ubuntu/ precise-updates main restricted
deb-src http://de.archive.ubuntu.com/ubuntu/ precise-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://de.archive.ubuntu.com/ubuntu/ precise universe
deb-src http://de.archive.ubuntu.com/ubuntu/ precise universe
deb http://de.archive.ubuntu.com/ubuntu/ precise-updates universe
deb-src http://de.archive.ubuntu.com/ubuntu/ precise-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://de.archive.ubuntu.com/ubuntu/ precise multiverse
deb-src http://de.archive.ubuntu.com/ubuntu/ precise multiverse
deb http://de.archive.ubuntu.com/ubuntu/ precise-updates multiverse
deb-src http://de.archive.ubuntu.com/ubuntu/ precise-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://de.archive.ubuntu.com/ubuntu/ precise-backports main restricted universe multiverse
deb-src http://de.archive.ubuntu.com/ubuntu/ precise-backports main restricted universe multiverse

deb http://security.ubuntu.com/ubuntu precise-security main restricted
deb-src http://security.ubuntu.com/ubuntu precise-security main restricted
deb http://security.ubuntu.com/ubuntu precise-security universe
deb-src http://security.ubuntu.com/ubuntu precise-security universe
deb http://security.ubuntu.com/ubuntu precise-security multiverse
deb-src http://security.ubuntu.com/ubuntu precise-security multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu precise partner
# deb-src http://archive.canonical.com/ubuntu precise partner

## Uncomment the following two lines to add software from Ubuntu's
## 'extras' repository.
## This software is not part of Ubuntu, but is offered by third-party
## developers who want to ship their latest software.
# deb http://extras.ubuntu.com/ubuntu precise main
# deb-src http://extras.ubuntu.com/ubuntu precise main

Then run

apt-get update

to update the apt package database and

apt-get upgrade

to install the latest updates (if there are any). If you see that a new kernel gets installed as part of the updates, you should reboot the system afterwards:

reboot

 

9 Change The Default Shell

/bin/sh is a symlink to /bin/dash, however we need /bin/bash, not /bin/dash. Therefore we do this:

dpkg-reconfigure dash

Use dash as the default system shell (/bin/sh)? <-- No

If you don't do this, the ISPConfig installation will fail.

 

10 Disable AppArmor

AppArmor is a security extension (similar to SELinux) that should provide extended security. In my opinion you don't need it to configure a secure system, and it usually causes more problems than advantages (think of it after you have done a week of trouble-shooting because some service wasn't working as expected, and then you find out that everything was ok, only AppArmor was causing the problem). Therefore I disable it (this is a must if you want to install ISPConfig later on).

We can disable it like this:

/etc/init.d/apparmor stop
update-rc.d -f apparmor remove
apt-get remove apparmor apparmor-utils

 

11 Synchronize the System Clock

It is a good idea to synchronize the system clock with an NTP (network time protocol) server over the Internet. Simply run

apt-get install ntp ntpdate

and your system time will always be in sync.

Share this page:

12 Comment(s)

Add comment

Comments

From: at: 2012-07-10 23:37:00

This server was problematic as far as configuration goes. There needs to be more detail into preparing the cfg files. I'm an Apache2 user normally and this install was just hassle loaded for me.

From: Senthil at: 2012-08-21 12:20:09

If you want to setup a mail server with following on Ubuntu 12.04 Precise Pangolin:

  • Dovecot 2.0.19
  • Postfix 2.9.3-2
  • Postfix Admin 2.3.5
  • Squirrel Mail 1.4.21
  • MySQL 5.5.24
  • PHP 5.3.10
  • Then lookup this page: http://tech.snathan.org/tech/linux/mail_server_setup

     

    From: Razooloo at: 2012-07-02 20:27:02

    hi

    this is a great manual big thank to Falko

    im trying to install dovecot-mysql dovecot-sieve

    and getting 

     E: Unable to locate package dovecot-mysql
    E: Unable to locate package dovecot-sieve
    if any one can help

    ' be real appreciated

    From: Imam86 at: 2012-08-01 00:50:27

    07-06-2012: Jailkit 2.15 released

    They resolved the issues:

    insserv: warning: script 'K01jailkit' missing LSB tags and overrides
    insserv: warning: script 'jailkit' missing LSB tags and overrides

     So the revision:

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

    cd ..
    dpkg -i jailkit_2.15-1_*.deb
    rm -rf jailkit-2.15*

    From: Mateusz J?drasik at: 2012-09-19 12:23:24

    Fail2Ban already has a pureftpd.conf file which looks like this:

    # Fail2Ban configuration file
    #
    # Author: Cyril Jaquier
    # Modified: Yaroslav Halchenko for pure-ftpd
    #
    # $Revision$
    #
    [Definition]
    # Error message specified in multiple languages
    __errmsg = (?:Authentication failed for user|Erreur d'authentification pour l'utilisateur)
    #
    # Option: failregex
    # Notes.: regex to match the password failures messages in the logfile. The
    #         host must be matched by a group named "host". The tag "<HOST>" can
    #         be used for standard IP/hostname matching and is only an alias for
    #         (?:::f{4,6}:)?(?P<host>[\w\-.^_]+)
    # Values: TEXT
    #
    failregex = pure-ftpd(?:\[\d+\])?: \(.+?@<HOST>\) \[WARNING\] %(__errmsg)s \[.+\]\s*$
    # Option:  ignoreregex
    # Notes.:  regex to ignore. If this regex matches, the line is ignored.
    # Values:  TEXT
    #
    ignoreregex = 



    Dovecot also seems covered:
     
    # Fail2Ban configuration file for dovcot
    #
    # Author: Martin Waschbuesch
    #
    # $Revision$
    #
    
    [Definition]
    
    # Option:  failregex
    # Notes.:  regex to match the password failures messages in the logfile. The
    #          host must be matched by a group named "host". The tag "<HOST>" can
    #          be used for standard IP/hostname matching and is only an alias for
    #          (?:::f{4,6}:)?(?P<host>[\w\-.^_]+)
    # Values:  TEXT
    #
    failregex = .*(?:pop3-login|imap-login):.*(?:Authentication failure|Aborted login \(auth failed|Aborted login \(tried to use disabled|Disconnected \(auth failed).*rip=(?P<host>\S*),.*
    
    # Option:  ignoreregex
    # Notes.:  regex to ignore. If this regex matches, the line is ignored.
    # Values:  TEXT
    #
    ignoreregex =   
     This is on Ubuntu Server 12.04.1 LTS on 19.08.2012.

    From: at: 2013-01-23 22:22:12

    Where is this file?

    From: ababneh at: 2013-03-08 16:15:40

    Hello,

     I followed this tutorial and get everything working, thank you. Just have one question. I have a folder with 15k files but the there is only 9998 files show in filezilla. I tried to locate the config file for pureftpd that contains the limit but I couldn't.  Could you please point that out?

     Thanks

    From: Andreas at: 2012-09-11 15:45:38

    I tried reinstalling ISP Config 3 two times, and im still unable to login as admin/admin.

    Keeps telling me wrong login.

    Any ideas?

    From: Yed at: 2013-05-08 12:44:29

    Exactly same here

    nginx installation

    From: Anonymous at: 2013-07-28 11:42:04

    I also get an error on trying to log in for the first time.

    "Username or password is empty"

    From: Indijus at: 2013-04-20 21:24:15

    Squirrlemail did not work for me. I always get 504 Gateway Time-out. The mail log shows that Apr 21 00:13:34 serveris postfix/smtps/smtpd[23659]: connect from localhost.localdomain[127.0.0.1]
    Apr 21 00:14:03 serveris postfix/smtps/smtpd[23740]: SSL_accept error from localhost.localdomain[127.0.0.1]: Connection timed out
    Apr 21 00:14:03 serveris postfix/smtps/smtpd[23740]: lost connection after CONNECT from localhost.localdomain[127.0.0.1]
    Apr 21 00:14:03 serveris postfix/smtps/smtpd[23740]: disconnect from localhost.localdomain[127.0.0.1]
    Apr 21 00:14:03 serveris postfix/smtps/smtpd[23740]: connect from localhost.localdomain[127.0.0.1]
    Apr 21 00:14:34 serveris postfix/smtps/smtpd[23659]: SSL_accept error from localhost.localdomain[127.0.0.1]: -1
    Apr 21 00:14:34 serveris postfix/smtps/smtpd[23659]: warning: TLS library problem: 23659:error:140760FC:SSL routines:SSL23_GET_CLIENT_HELLO:unknown protocol:s23_srvr.c:628:
    Apr 21 00:14:34 serveris postfix/smtps/smtpd[23659]: lost connection after CONNECT from localhost.localdomain[127.0.0.1]
    Apr 21 00:14:34 serveris postfix/smtps/smtpd[23659]: disconnect from localhost.localdomain[127.0.0.1]
    Apr 21 00:15:01 serveris postfix/smtps/smtpd[23659]: connect from localhost.localdomain[127.0.0.1]
    Apr 21 00:15:01 serveris postfix/smtps/smtpd[23659]: SSL_accept error from localhost.localdomain[127.0.0.1]: lost connection
    Apr 21 00:15:01 serveris postfix/smtps/smtpd[23659]: lost connection after CONNECT from localhost.localdomain[127.0.0.1]

    Apr 21 00:15:01 serveris postfix/smtps/smtpd[23659]: disconnect from localhost.localdomain[127.0.0.1]


    Whats wrong with my server.Please help me

    From: sertaconay at: 2014-01-15 21:07:20

    Hello.

     I think your configuration for Squirrelmail is wrong. It gives 404 error after trying to send email. Because it rewrites url twice like "squirrelmail/src/compose.php/squirrelmail/src/". 

    I tried this configuration and it's OK.

    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;

                   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;

    }