How to deploy Zimbra ZCS Open Source Edition on Amazon EC2

This guide should help you deploy Zimbra ZCS 7.1.3_GA on an Ubuntu 10.04 instance with Amazon EC2.


1) Ensure you have set up Amazon EC2 CLI scripts …

Download tools from here

Generate certificates in the security credentials section of AWS control panel

Set up environment variables in your .bash_profile (using your key paths, and your preferred EC2 region)

export EC2_PRIVATE_KEY=/path/to/ec2-private-key.pem
export EC2_CERT=/path/to/ec2-cert.pem
export EC2_URL=

2) Ensure you have imported your public ssh key (replace paul-public-key with whatever label you want to use)

for r in us-east-1 us-west-1 ap-southeast-1 eu-west-1; do ec2-import-keypair --region $r paul-public-key --public-key-file ~/.ssh/ ; done

3) Setup an elastic IP, and then create DNS entries for your mail server, that point to that IP. Let’s assume you are going to call your mail server, you will need records in’s zone for:

mail1 CNAME
mail1 MX 10 mail1

Where xxx-xxx-xxx-xxx is your elastic IP. For other domains, you can then point their MX records to

4) Setup a security group for your Zimbra server with the desired ports open (25,80,443, 110, 143, 389, 443, 993, 995, 7071, 7110, 7995, 7143, 7993 etc… ).

ec2-create-group "Zimbra ZCS" -d "Zimbra Collaboration Suite Group"
ec2-authorize "Zimbra ZCS" -P icmp -t -1:-1
ec2-authorize "Zimbra ZCS" -P tcp -p 22
ec2-authorize "Zimbra ZCS" -P tcp -p 25
ec2-authorize "Zimbra ZCS" -P tcp -p 80
ec2-authorize "Zimbra ZCS" -P tcp -p 7071


1) Launch a new instance. Replace paul-public-key with the name of your public key (this will need to have been imported into AWS previously). The -g switch refers to your security group. We are using 100GB as the main disk size, as by default they are too small for a Zimbra installation.

// This will launch a new launch instance of Ubuntu 10.04 LTS
ec2-run-instances -t m1.large -g "Zimbra ZCS" -k paul-public-key -b "/dev/sda1=:100:false" ami-cc0e3cb8 --region eu-west-1

2) SSH in and resize the filesystem to the full disk size. Run ec2-describe instances to find your new instance’s IP address, then ssh in to it and resize the file system.

ssh ubuntu@your-instance-public-ip
sudo su -
resize2fs /dev/sda1

3) Assign the elastic IP you chose earlier

// Check your instances ID
// Associate the address to the instance
ec2-associate-address ELASTIC_IP_ADDRESS -i INSTANCE_ID

4) Set up hostname on the system

echo '' > /etc/hostname
echo ' mail1' >> /etc/hosts

Then check it works with..

hostname --fqdn

IMPORTANT: The commands above specify as the IP for the system’s hostname in /etc/hosts. You need all 3 fields listed in /etc/hosts (eg. mail1) – otherwise LDAP install fails as it tries to connect to resolved elastic IP. In addition, use a CNAME for the public DNS MX records hostname instead of A record, then when it is resolved internally, it should get a local IP, which should assist postfix with LMTP lookups. If you don’t do this you will get issues – – A crude fix is to open port 7025 in the security group, but the CNAME is better.
4) Download Zimbra

cd /root/ 
mkdir zimbra
cd zimbra
// Download the appropriate version for your Linux distribution (and architecture, e.g. 64 bit)
tar -xvzf zcs-7.1.3_GA_3346.UBUNTU10_64.20110928134610.tgz

5) Install dependencies

apt-get install libperl5.10 sysstat sqlite3

6) Install Zimbra (this takes about 10-15 minutes)


Keep all default settings and proceed with install

When it complains “DNS ERROR – none of the MX records for resolve to this host” say No to change domain name.

Set password… at menu (make a note of it).

Apply changes.

You can login to the web interface with:

u: [email protected]
p: whatever you set in the install script

Try sending a test e-mail to [email protected] – you should be able to log in to the web interface and view it.

References: – Ubuntu Image List – Zimbra Downloads


Installing Zend Framework on Ubuntu (Hardy)

As of the 8.04 Hardy release of Ubuntu, Zend Framework has been added to the repositories, so you can install it by simply running:

sudo apt-get install zend-framework

The package installs 17M of files into /usr/share/php/libzend-framework-php/.

Once that has finished, you then need to ensure that the framework is in your PHP include path. The best way to do this is to add the include to your PHP scripts directly, or better still via a global include file. The line you would need to add is:


An example project would then look like:

require_once 'Zend/Mail.php';
$mail = new Zend_Mail();
$mail->setBodyText('My Nice Test Text');
$mail->setBodyHtml('My Nice Test Text');
$mail->setFrom('[email protected]', 'Mr Example');
$mail->addTo('[email protected]', 'Mr Test');

As Andy pointed out in a comment, Zend Framework is evolving quite rapidly, so if the Ubuntu repository version fails to meet your needs, then you could easily install and switch to a newer version for certain projects if you modify the include path this way.

Installing the Brother MFC-9840CDW on Ubuntu

To install a Brother MFC 9840 CDW printer on Ubuntu, you must:

  1. Download the LPR driver from here
  2. Download the CUPS wrapper driver from here.
  3. Install them.

You can use these commands:

sudo mkdir /var/spool/lpd
sudo mkdir /usr/share/cups/model
sudo chmod 777 /usr/share/cups/model
sudo dpkg -i --force-all --force-architecture mfc9840cdwlpr-1.0.0-7.i386.deb
sudo dpkg -i --force-all --force-architecture mfc9840cdwcups-1.0.0-7.i386.deb
sudo aa-complain cupsd

One blog reader, Hans, has commented that you can just use synaptic to install the printer drivers. I haven’t tried this myself so I would be interested to hear how others get on using this method. Please post a comment if it worked for you!

  • Open up Synaptic Package Manager.
  • Search for 9840 and install the packages.
  • Set it up under System > Printers.

rtorrent: Error in option file

My bit torrent client of choice is rtorrent, which runs from the command line. I have been using it without problems for months, but today it stopped working and gave an error instead:

rtorrent: Error in option file: ~/.rtorrent.rc:4: Not a value

It seems that the rtorrent developers have made some changes to the way it handles its config files, and they are not backwards compatible. So when Ubuntu upgraded my rtorrent package, it broke.

To fix this you must check all your configuration settings against the new config syntax. You can see a list of valid configuration settings in /usr/share/doc/rtorrent/examples/rtorrent.rc

There were a number of settings I needed to change, but a common one that will probably cause a lot of people problems is the upload / download rate.

Old Syntax

upload_rate = 25KB
download_rate = 400KB

New Syntax

upload_rate = 25
download_rate = 400

Setting up asterisk-gui on Ubuntu

Tonight I had a go at installing Digium’s asterisk-gui. I followed some instructions from Asterisk Guru, but then had to apply a fix at the end because the static-http folder was in the wrong place.

Installation Instructions

Download the asterisk-gui source code from SVN:

mkdir -p ~/downloads/asterisk-gui
cd ~/downloads/asterisk-gui
svn checkout .

Compile the source code:

./make install

Backup your asterisk config:

cp -r /etc/asterisk /etc/asterisk.backup

Install the sample settings if you wish (this adds things like a list of VOIP providers to use as a PSTN gateway).

./make samples

Edit /etc/asterisk/manager.conf to enable the web management interface and to add a user:

enabled = yes
webenabled = yes
secret = YoUrPaSwOrD
read = system,call,log,verbose,command,agent,user,config
write = system,call,log,verbose,command,agent,user,config

Edit /etc/asterisk/http.conf to enable asterisk’s mini webserver. If you are accessing from your local machine use otherwise you might want to bind to a public ip, but be aware this is less secure.


Run make checkconfig to verify your configuration settings:

./make checkconfig

I then had to do an additional step to link the static http scripts folder to inside /usr/share/asterisk as it seems asterisk was looking in here instead of /var/lib/asterisk/

sudo ln -s /var/lib/asterisk/static-http/ /usr/share/asterisk/

After that you should be able to login to the control panel at (replacing the IP address with whichever one you chose).

Missing asterisk config files in Ubuntu / Debian

If you install Asterisk on Ubuntu via apt-get, and then remove it and re-install again, you may find that you are missing the all the config files in /etc/asterisk.

This is a bug in the debian asterisk package that means that the config files are deleted when you remove the asterisk package even though they are part of the asterisk-config package.

To fix it simply run the following commands: (NB: This will nuke any asterisk installation you have)

sudo dpkg --purge asterisk
sudo dpkg --purge asterisk-config
sudo apt-get install asterisk-config
sudo apt-get install asterisk

Installing phpMyAdmin Advanced Features on Ubuntu


To install the advanced features of phpMyAdmin you have to create a special control database that PMA uses to store bookmarks and relationships etc… PMA comes with a script called create_tables.sql that contains the relevant sql statements to set these tables up. Normally, when you install phpMyAdmin directly from source, this create_tables.sql script can be found in the scripts sub-folder.

Today I was feeling lazy so I decided to use apt-get to install PMA on my Ubuntu machine. However, when I went to enable advanced features, the scripts sub folder was pretty much empty (except for a setup.php script). It seems that with the debian package the advanced feature scripts have been moved to /usr/share/doc/phpmyadmin/examples – It took me ages to work this out, so hopefully this post might save someone some time!

Firstly, unzip and run the create_tables.sql file:

cd /usr/share/doc/phpmyadmin/examples
sudo gunzip create_tables_mysql_4_1_2+.sql.gz 
mysql -u root -p < create_tables_mysql_4_1_2+.sql

Then setup a user/password for phpMyAdmin to use:

mysql -u root -p -e 'GRANT SELECT, INSERT, DELETE, UPDATE ON `phpmyadmin`.* TO 'pma'@'localhost' IDENTIFIED BY "password"'

Then edit the config file, and uncomment the advanced features options for your chosen server, and add the user / password you setup in the previous step. If you haven't edited this file before you may need to also uncomment the rest of the server definition.

sudo vim /etc/phpmyadmin/

Encoding mp3 audio with ffmpeg on Ubuntu Hardy

If you already have ffmpeg installed (without mp3 support), then firstly uninstall it.

MP3 support isn’t included with ffmpeg in the default Ubuntu repositories so to get it you have to enable the Medibuntu repos (assuming this is legal in your area).

sudo wget -O /etc/apt/sources.list.d/medibuntu.list
wget -q -O - | sudo apt-key add - && sudo apt-get update

Then you can install ffmpeg and the libmp3lame codec (part of the libavcodec package)

sudo apt-get install ffmpeg
sudo apt-get install libavcodec1d

You can verify the dependencies of ffmpeg with ldd

paul@paul:~/Videos$ ldd /usr/bin/ffmpeg =>  (0xb7f07000) => /usr/lib/ (0xb7e72000) => /usr/lib/ (0xb7997000) => /usr/lib/ (0xb798c000) => /lib/tls/i686/cmov/ (0xb7967000) => /lib/tls/i686/cmov/ (0xb794f000) => /lib/tls/i686/cmov/ (0xb7800000) => /usr/lib/ (0xb77eb000) => /usr/lib/ (0xb77e6000) => /usr/lib/ (0xb77d6000) => /lib/tls/i686/cmov/ (0xb77d2000) => /usr/lib/ (0xb77c7000) => /usr/lib/ (0xb77ba000) => /usr/lib/ (0xb7725000) => /usr/lib/ (0xb76db000) => /usr/lib/ (0xb76b3000) => /usr/lib/ (0xb75ba000) => /usr/lib/ (0xb74a2000) => /usr/lib/ (0xb7417000) => /usr/lib/ (0xb7406000)
	/lib/ (0xb7f08000) => /usr/lib/ (0xb73ff000) => /usr/lib/ (0xb7318000) => /usr/lib/ (0xb7316000) => /usr/lib/ (0xb72fe000) => /usr/lib/ (0xb72fa000) => /usr/lib/ (0xb72f5000)

It should then let you encode videos with mp3 audio…

ffmpeg -i jonathan-davis-news24-2008-01-22.avi -f flv -s 400s220 -acodec mp3 -ar 44100 jd.flv

Real media to Xvid (divx) and cropping with Ubuntu

If you liked my last post on how to save real player streams and convert them to mpeg 4 avi files, then you might find this post useful.

Today I needed to save a real player stream of last night’s 10 o’clock news from the BBC and then convert it into an xvid file. I also wanted to crop it down to just show the particular news item we were interested in (a feature about one of our sites). This is how I did it:

  1. First follow the steps on how to install mencoder and then dump the ram stream as per my previous post.
  2. Next convert the dump file to xvid with the following command:

    mencoder stream.dump -o bbc-10oclocknews.avi -ovc xvid -xvidencopts bitrate=128 -oac mp3lame

  3. Now use Avidemux to crop the video file. If you haven’t already got this program you can install with

    sudo apt-get install avidemux

  4. Open the video file with Avidemux, and then ensure the video and audio are in sync by selecting Audio > Build VBR timemap from the menu.
  5. Use the selection Markers to chop out bits you don’t want (or select the bit you do want), and then save the resulting video with File > Save > Save Video
      And that’s it! Here is the resulting file:

Converting RealPlayer .rm files to MPEG (mp4) .avi with Ubuntu

You will need mplayer and mencoder, as well as the win32 codecs in order to convert .rm files to their mpeg equivalent. So if you haven’t already got them installed you can get them with:

sudo apt-get install mplayer mencoder
tar jxfv essential-20071007.tar.bz2
sudo mkdir -p /usr/lib/win32
sudo mv -i essential-20071007/* /usr/lib/win32/

Next you need to download the realplayer feed you want to convert. First of all download the realvideo file you want and then view it to see the realtime streaming protocol (RTSP) url inside:

cat politicsshow_16x9_bb.ram
// displays something like rtsp://

Now you can use mplayer to dump the stream to your local disk:

mplayer -dumpstream rtsp://

This will take as long as it would take to view the stream normally. Once it’s finished you can then use mencoder to convert the stream to your required file format. To have H264 (mpeg 4) video, and mp3 audio you would use:

mencoder stream.dump -o bbc-politics.avi -ovc x264 -oac mp3lame

You can get a list of all supported formats with mencoder -ovc help.