Tuesday, January 20, 2009

HowTo - The Perfect Debian 4 and Zimbra 5 Small Business Server

Introduction

This guide will show you how to install a Linux server. After completion, you'll have the following capabilities:
  • Retrieve email from a remote POP account and deliver it to a local user
  • Access your email locally, through webmail, Thunderbird, or Outlook
  • Access your email remotely, through webmail, while on the road (if you choose to)
The environment that this server will integrate into is as follows:
  • Website hosted by an outside service
  • POP email accounts hosted by the same outside service
  • High-speed Internet connection
  • An Internet router/firewall device
Because this server is geared towards a small (and possibly medium) sized business, I do not want that business to host the website and the email. Why? The website for a business has to be up 24/7/365 with 99.99% uptime. A small business (in my opinion) can neither afford the infrastructure to maintain such a system, nor can they afford to hire talented personnel to maintain it. And even with all that hardware and expertise, all it takes is a power failure to last longer than your battery backups, and you're down.

For this tutorial, we're going on the assumption that your company is called Example. Your website is called Example.com. And, one of your email addresses is sales@example.com. All this is hosted by XYZ company, whose website is xyz.com.

Here's the software we're going to install.
I've chosen this configuration for a few reasons. One is I love Debian. It's rock-solid. Easy to update through its excellent package management system, and easily upgraded to the new major release (Debian 5.0, codenamed Lenny, in testing as of this writing).

Zimbra is a self-contained collaboration suite, complete with antispam and antivirus capabilities. It's a turnkey system. Included in the open source version is a foundation for cloud computing -- being able to store documents in Zimbra, accessible and editable through the web interface.

Both Debian and Zimbra are stable and mature. It makes an excellent combination for a server.

What You'll Need

Zimbra recommends a 2.0 GHz CPU or faster, with 2+ Gigs of RAM. For hard drives, I always recommend at least a RAID 1 configuration.
  • A late model computer (somewhere in the 2+ Gigahertz range)
  • At least 2 Gigabytes of RAM
  • Plenty of hard drive space (preferably in a RAID-1 setup)
  • Debian installation media, downloadable from here
The exact partitioning scheme is up to you. I cannot cover that here. I'm going to use the default partition scheme the CentOS installer uses. So, let's get going!

Installing Debian Etch

Insert the Debian boot CD in the drive and boot the computer. I'm using the debian-40r5-i386-CD-1.iso disk image.


Press Enter to boot the system


Select the language to use for installation


Select your country


Select your keyboard. Hardware detection will take place now, and could take a few minutes.


Enter your hostname. Here, I use server


Enter your domain name. Here, I use local.zzz.


Choose Guided - use entire disk for partitioning


Choose the disk to partition


Choose All files in one partition


Choose Finish partitioning and write changes to disk


Choose Yes to write partitions to disk


Choose your timezone


Choose your root password


Verify your root password


Select your username


Choose a login (if you don't like the suggestion)


Choose a password


Verify your password. The base system will be installed. This will take a few minutes


Use Network mirror. Select no. (We'll update the system later. Let's just use the CD)


Choose whether or not to participate in the package survey. No is fine.


Choose Continue, as the default software selection is fine.


Set your video resolution


Install GRUB


And reboot into your new Debian system


Looks like GDM. Let's login


The desktop. And it warns us to update packages. But we won't update it via the GUI tool.

Open a terminal (Applications - Accessories - Teminal) and as root, edit the following file.

/etc/apt/sources.list -- Modify this file

# deb cdrom:[Debian GNU/Linux 4.0 r5 _Etch_ - Official i386 CD Binary-1 20081023-23:20]/ etch contrib main

deb http://http.us.debian.org/debian/ etch main contrib non-free
deb-src http://http.us.debian.org/debian/ etch main contrib non-free

deb http://security.debian.org/ etch/updates main contrib
deb-src http://security.debian.org/ etch/updates main contrib


The cdrom line should be commented out, unless you have a disk that has updates that you'd like to install from. The security lines are repositories for security updates. Software is in the 2 added lines, and will give you access to everything you should ever need. Also, by using the name etch instead of stable will insure you stay on Debian 4 when Debian 5 (Lenny) becomes stable.

Then, at the root command prompt, enter:
  • aptitude update
  • aptitude upgrade -y
This will refresh the local list of available software, and the second line will perform the update. Now your system is up to date, and has lots of software available through the package manager.

Sometimes you'll get a warning telling you the kernel is either being upgraded, or updated. Either way, you'll have to do a reboot to utilize the new kernel (and avoid problems down the road)

Configure a static IP

/etc/network/interfaces -- Modify this file

# 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
allow-hotplug eth0
iface eth0 inet static
address 192.168.1.2
netmask 255.255.255.0
network 192.168.1.0
gateway 192.168.1.1
broadcast 192.168.1.255


Modify according to your network settings and interface name. After modifying the file, reboot the computer. Open a root terminal and confirm the new network settings with ifconfig.


Install DNS

Now we need to install a DNS server for Zimbra. In a root terminal window, enter the following:
  • apt-get install -y bind9

/etc/hosts -- Modify this file

127.0.0.1        localhost.localdomain localhost
192.168.1.2 server.local.zzz server

# 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
ff02::3 ip6-allhosts


Feel free to leave in any IPv6 addresses.

/etc/resolv.conf -- Edit this file

search local.zzz
nameserver 192.168.1.2


/etc/bind/named.conf.local -- Edit this file

zone "local.zzz" {
type master;
file "/etc/named.zzz.fwd";
};

zone "1.168.192.in-addr.arpa" {
type master;
file "/etc/named.zzz.rev";
};

options {
forwarders { 192.168.1.1; } ;
};


/etc/bind/named.zzz.fwd -- Create this file

local.zzz   IN      SOA     server.local.zzz.        root.local.zzz. (
2009011501 ; Serial in YYYYMMDDXX - tab indented
28800 ; Refresh
3600 ; Retry
604800 ; Expire
14400 ; Default TTL
)

local.zzz. IN NS server.local.zzz.
local.zzz. IN MX 10 server.local.zzz.

mta IN A 192.168.1.2
server IN A 192.168.1.2
www IN A 192.168.1.2


/etc/bind/named.zzz.rev -- Create this file

@       IN      SOA     server.local.zzz.        root.local.zzz. (
2009011501 ; Serial
28800 ; Refresh
3600 ; Retry
604800 ; Expire
38400 ; Default TTL
)

IN NS server.local.zzz.
2 IN PTR server.local.zzz.
2 IN PTR local.zzz.


At a root terminal window, enter
  • /etc/init.d/bind9 force-reload
DNS should be up and running


Install Additional Software For Zimbra


Zimbra needs some additional software in order to function on Debian. Here's what to add

  • apt-get install -y fetchmail libgmp3c2 libltdl3
  • apt-get remove –purge exim4 exim4-base exim4-config exim4-daemon-light network-manager
This is all the dependencies Zimbra needs to install.

Install Zimbra


Download the Zimbra Open Source package from here. You'll want to download the Debian 4 package. After the download is complete, open a root terminal and cd into the directory where the download . In my case, it's in root's home directory.
  • cd /root (or to where you downloaded the tarball
  • tar xfz zcs-5.0.11_GA_2695.DEVIAL4.0.20081117055537.tgz
  • cd zcs-5.0.11_GA_2695.DEVIAL4.0.20081117055537.tgz
  • ./install.sh
The installer will check to see what's installed. Being a fresh install, you'll have a series of NOT FOUND. At the end, press Return to continue

The installer checks for needed packages. If it finds everything it needs, it will then search for what's available to install (ie, what's in the extracted archive). Now it will ask you what to install, item by item.


Install zimbra-ldap [Y]                   --  Press Enter
Install zimbra-logger [Y] -- Press Enter
Install zimbra-mta [Y] -- Press Enter
Install zimbra-snmp [Y] -- Press Enter
Install zimbra-store [Y] -- Press Enter
Install zimbra-apache [Y] -- Press Enter
Install zimbra-spell [Y] -- Press Enter
Install zimbra-proxy [N] -- Press Enter

Checking required space for zimbra-core
checking space for zimbra-store

Installing:
zimbra-core
zimbra-ldap
zimbra-logger
zimbra-mta
zimbra-snmp
zimbra-store
zimbra-apache
zimbra-spell

The system will be modified. Continue? [N] -- Enter Y and press Enter


Note:
I get a DNS warning message. You'll be asked if you want to reconfigure your domain name. Enter NO. Even though the installer warns of an incorrect MX record, it will not prevent mail retreival via POP or IMAP. If this were to be a 'real' mail exchanger, it would be an issue. I'm working on an alternative DNS config, and will post it when completed. This will, however, depend heavily on the configuration of DynDNS.



Several packages will now be installed. The next screen come up to configure Zimbra. The only thing that needs to be configured is the Administrator password. Enter 3, and 4. Enter the password. Enter R to return to the previous menu. Enter A to apply the settings. And Enter again to save the configuration data to a file. The default config file should suffice. Rename it if you like, or press Enter. Enter Yes to modify the system and finalize the install.

You'll be asked whether you want to notify Zimbra of your installation. Enter your desired response and press Enter.

A few more items will be setup. After it's finished, press return to exit.

Getting Your Email

Each user has the option of configuring external accounts. This is done through the Preferences, Accounts tab in the webmail interface. More information can be found in Zimbra's docs.



That's it! Enjoy your Zimbra email server!


No comments: