Simple Mail Server Architecture

Setup Zimbra Mail Server in CentOS

Hello and welcome back to my next blog! In this post, I’m going to share how to setup Zimbra Mail Server in CentOS server. Since I’m going to cover this topic from start to end, it might be a long read and I hope you’ll manage to go through it. Just to give you a brief introduction of Zimbra, ZCS is one of the World’s largest open-source collaboration projects and it is an ideal solution for all sorts of mail related requirements. It basically comes with two offerings: Network Edition and Community Edition. As indicated by the terms themselves, Network Edition is a paid solution as we have to purchase its license on per user bassis and it includes support from Zimbra itself. Whereas, Community Edition is a free and open-source solution, however the Zimbra community is responsible for support related to it. And here, I’m entirely writing about Community Edition.




Zimbra Logo
Zimbra Logo
Lab Overview

For this setup, I’m using CentOS 7.1 Minimal server as the host operating system inside VMware vSphere 5.5. The version of Zimbra I’m using here is ZCS 8.6 GA. Note that, the installation and setup procedure might be a little different if you’ve different version. The system specification for ZCS are as follows:

  • RAM: 8 GB recommended
  • CPU: 4 vCPU
  • Storage: 500 GB

Note: You can allocate system resources as per your requirements. If you’re just trying to learn or test Zimbra, you can begin with little hardware resources. However, if you’re planning on taking this setup to production, you must fulfill the minimum requirements and try for recommended values.

Before getting started with the installation of Zimbra Collaboration Server, I recommend you to read and follow these pre-requisite blog posts to be on the same page as I’m while starting the setup procedure. If you’re already quite familiar with the creation of VM, installation and initial configuration of CentOS Minimal server, then you can simply skip reading these blog posts.

In the above mentioned blog posts, I’ve basically focused on CentOS 6.5 Minimal server, so there will be some variations throughout the installation and initial configuration sections. To be specific, disk partitioning is a bit different between CentOS 6.5 and CentOS 7.1. In CentOS 6.5, we need to choose the partition type (eg. Standard or LVM) first and then allocate it to system partition. Whereas in CentOS 7.1, we need to first add and allocate a partition, and then define its partition type and Logical Volume arguments if using LVM.

Here’s my partition table layout:

  • /boot: Standard Partition and 500 MB
  • swap: LVM Volume and 8 GB
  • /: LVM Volume and 5 GB
  • /tmp: LVM Volume and 5 GB
  • /opt: LVM Volume and rest of the disk space
Preparing Server for Zimbra

Now, let’s get into the actual setup procedure. You might have already learned and performed the initial configuration of your CentOS machine as of now, however, I’m going to perform some configuration again before installing Zimbra. Let’s begin with the setup of network.

[code][root@localhost ~]# ip link show[/code]

Note the name of the ethernet interface connected to your server. In case you’re using multiple network interfaces, take the one you want to configure here. Then, edit the config for that particular interface. In case my case, it is named as eth0, so I’m network config looks like this:

[code][root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=static
IPADDR=10.10.10.10
NETMASK=255.255.255.0
GATEWAY=10.10.10.1
DNS1=8.8.8.8[/code]

Then, let’s configure server’s hosts file. My hosts file looks like this:

[code][root@localhost ~]# vi /etc/hosts
127.0.0.1 localhost
10.10.10.10 mail.sajjan.com.np mail[/code]

Let’s also change the hostname of this server to the appropriate name.

[code][root@localhost ~]# vi /etc/sysconfig/network
HOSTNAME=mail.sajjan.com.np[/code]

After that, let’s install some of the necessary packages or dependencies for Zimbra server. While doing so, I’m also installing EPEL repository for the software packages that I’m going to install here.

[code][root@mail ~]# yum -y install epel-release
[root@mail ~]# yum -y update[/code]

If you’re familiar with older versions of CentOS, then you should know that they use Iptables as  their default firewall. However, CentOS 7 implements Firewalld for this purpose. I found Firewalld a little difficult at first, but it got a lot better and intuitive once I started to understand it. Since its minimal version doesn’t ship with Firewalld, we need to install and enable it. Before installing, let’s check its availability in our system.

[code][root@mail ~]# rpm -qa | grep firewalld
[root@mail ~]# yum -y install firewalld
[root@mail ~]# systemctl stop firewalld
[root@mail ~]# systemctl enable firewalld[/code]

There’s also anther very important thing that should be taken care of while installing Zimbra, i.e. the Postfix server that comes by default with CentOS. Postfix is a mail transport agent (MTA) and is responsible for sending and receiving mails. However, Zimbra itself ships with Postfix inside its framework. So, if we don’t stop and disable native postfix of CentOS, we’ll end up having conflict between these two. Therefore, it is very important to stop and disable Postfix before going further in Zimbra.

[code][root@mail ~]# systemctl status postfix
[root@mail ~]# systemctl stop postfix
[root@mail ~]# systemctl disable postfix[/code]

The next thing we need to take care of is the SELinux. Since Zimbra is a collaboration of numerous open-source projects and some of the components might not perform well when SELinux is enforced, we need to either disable it or set it to permissive mode.

[code][root@mail ~]# sestatus
[root@mail ~]# setenforce 0
[root@mail ~]# sed -i s/"SELINUX=enforcing"/"SELINUX=permissive"/g /etc/sysconfig/selinux[/code]

Now, we can install the dependencies for Zimbra. You can run the below command to do this.

[code][root@mail ~]# yum -y install perl perl-core screen w3m elinks bind bind-utils unzip sed nc sysstat libaio rsync telnet aspell net-tools[/code]

Then, regarding the installation of VMware tools, I’ve already covered it in the above mentioned blog posts. However, since I did it in CentOS 6.5, it’ll be a bit different in CentOS 7. Specially, if you don’t install net-tools before trying to install VMware tools, your installation will fail because the install script will be running ifconfig command during setup. As you might have already guessed, ifconfig is a part of net-tools package.

Optionally, we can also use NTP for time and date update. To configure NTP, we need to add the NTP server in the respective config file. In my case, my NTP server is hosted in 10.10.10.100, so I set it up like this.

[code][root@mail ~]# vi /etc/ntp.conf
server 10.10.10.100 iburst
[root@mail ~]# ntpdate 10.10.10.100[/code]

Setting Up BIND

After having basic configuration in CentOS server, I move into another important step for setting up Zimbra i.e. hosting DNS server. Here, I’m using BIND (Berkeley Internet Name Domain) as the DNS server of choice. We’ve already installed BIND above by installing bind and bind-utils packages. Now, we can start modifying related configuration files to make it work as per our requirements. First, let’s backup the original config file for safety.

[code][root@mail ~]# cp /etc/named.conf /etc/named.conf.orig[/code]

Then, let’s make necessary changes as follows:

[code][root@mail ~]# sed -i s/"listen-on port 53 { 127.0.0.1; };"/"listen-on port 53 { 127.0.0.1; any; };"/g /etc/named.conf
[root@mail ~]# sed -i s/"allow-query { localhost; };"/"allow-query { localhost; any; };"/g /etc/named.conf[/code]

Then, append following lines at the end of /etc/named.conf file. Doing this will add a zone in the DNS server which will take the DNS entries from the file called db.sajjan.com.np placed inside the directory /var/named.

[code]zone "sajjan.com.np" IN {
type master;
file "db.sajjan.com.np";
allow-update { none; };
};[/code]



After configuring the named.conf file, let’s define the database file that we called above. My DNS database file looks like this:

[code][root@mail ~]# vi /var/named/db.sajjan.com.np
$TTL 1D
@ IN SOA ns1.sajjan.com.np. root.sajjan.com.np. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
@ IN NS ns1.sajjan.com.np.
@ IN MX 0 mail.sajjan.com.np.
ns1 IN A 10.10.10.10
mail IN A 10.10.10.10[/code]

After creating this database file, make sure that the “named” user has ownership of this file. Otherwise, the DNS server or “named” daemon cannot come online.

[code][root@mail ~]# chown named:named /var/named/db.sajjan.com.np[/code]

Then, let’s start our name server.

[code][root@mail ~]# systemctl start named
[root@mail ~]# systemctl enable named[/code]

To complete our name server deployment, let’s configure our system to use the newly configured DNS server. We can do this by replacing the server address of DNS1 with this server’s IP address in interface’s config file. We can also define nameserver as this server’s IP address in resolv.conf file. Here, I’m doing both for your reference.

[code][root@mail ~]# sed -i s/"DNS1=8.8.8.8"/"DNS1=10.10.10.10"/s /etc/sysconfig/network-scripts/ifcfg-eth0
[root@mail ~]# vi /etc/resolv.conf
search sajjan.com.np
nameserver 127.0.0.1[/code]

At last, let’s verify the functioning of our newly installed name server using nslookup and dig. You can use the lookup tool of your choice.

[code][root@mail ~]# nslookup mail.sajjan.com.np
[root@mail ~]# dig mx sajjan.com.np[/code]

Installation of Zimbra

Finally…., after so long, we’ve come to the point where we can begin the installation of Zimbra. Till now, we’ve already performed the pre-installation configuration and installation of dependencies for Zimbra. So, we’re ready to get this through. First, let’s download the ZCS package from Zimbra’s download page. If you have already downloaded it in your PC, you can upload the package to server using any SFTP client like PSFTP or other FTP clients. If you haven’t downloaded it already in your PC and would like to download it directly in your server, you can use wget to get it.

[code][root@mail ~]# cd /tmp
[root@mail tmp]# wget https://files.zimbra.com/downloads/8.6.0_GA/zcs-8.6.0_GA_1153.RHEL7_64.20141215151110.tgz
[root@mail tmp]# tar xzvf zcs-8.6.0_GA_1153.RHEL7_64.20141215151110.tgz
[root@mail tmp]# cd zcs-8.6.0_GA_1153.RHEL7_64.20141215151110
[root@mail zcs-8.6.0_GA_1153.RHEL7_64.20141215151110]# ./install.sh –platform-override[/code]

This installation script will take us through a series of user-friendly prompts and questions. It’ll ask us to agree with the GPL license, select the Zimbra components to install, and so on. One place the install script will more likely give an error is the domain name. It’ll tell you that your configured domain name (in my case, mail.sajjan.com.np) isn’t a Fully Qualified Domain Name or something like that. In that case, it’ll ask if you’d like to change your domain name. Enter Yes and provide your domain name to it (in my case, sajjan.com.np). Despite that, there won’t be any error unless you’ve messed up something in the earlier steps.

At the end of the installation, Zimbra will ask you to complete any incomplete tasks which are marked with “*“. Basically, you’ll need to set your password for admin account (admin@sajjan.com.np). If you would like to make any more changes to your setup, this is the right time to do it before completing the installation process. After you’re done making any changes, you can save the configuration, apply it and quit the setup. Now, your Zimbra setup is ready for use. You can also access its Web panel by browsing https://10.10.10.10:7071 from your web browser.

 Post-Installation Tasks for Zimbra

Since, this blog article has already been too long and there is a good chance that you’ll be facing some problems up to now, I’m ending this post here. I’ll continue the post-installation part of Zimbra in the following blog post (Read here). If you’re facing any issue with the above mentioned steps or having any inquiry for me, please let me know in the comments section. I hope you’ve found it informative and helpful. Thank you!





Comments

4 responses to “Setup Zimbra Mail Server in CentOS”

  1. […] If you’ve been following up with my previous blogs, it is a continuity to my last blog on how to setup Zimbra mail server in CentOS. Till now, I’ve already covered the preparation and installation of ZCS package. From here, […]

  2. Great job! Very informative and easy to follow article. Thank you.

    1. Thanks Artyom! 🙂

  3. Jacek Szemplinski Avatar
    Jacek Szemplinski

    Could you explain db and named.conf files in DNS configuration? This is the hardest part. For example in db file you have: “3H ) ; minimum”. Why the sign “)” is in this place? What does the “@” mean?
    I found about 10 examples of these files. Everyone was different.

Leave a Reply

Your email address will not be published. Required fields are marked *