Difference between revisions of "Building Zimbra on Gentoo"
m (→Stopping Apache on the Gentoo host) |
|||
(38 intermediate revisions by 6 users not shown) | |||
Line 1: | Line 1: | ||
− | Here's a howto that will get Zimbra going on a Gentoo install. This method basically leverages debootstrap to get a bare debain sarge install in a chroot environment. The open source zimbra | + | {{Archive}}{{Article Infobox|{{devel}}||{{ZCS 5.0}}|}}Here's a howto that will get Zimbra going on a Gentoo install. This method basically leverages debootstrap to get a bare debain sarge install in a chroot environment. The open source zimbra 5.0.9 package for Debian can then be installed. This is working on Gentoo 2008.0 kernel 2.6.25-gentoo-r7. But you shouldn't have any issues running it on recent versions. At first this may seem like extra work and a waste of resources, but to the contrary running Zimbra in a chroot is a pretty good idea. People have been hosting chroot jails on *BSD's to run various internet services for quite some time. This can add a level of protection for the host system. I.e. if the unthinkable happens and an attacker does find a way to gain root through the host services on your Zimbra instance, (s)he will only have access to the chroot environment. |
== Stopping Apache on the Gentoo host == | == Stopping Apache on the Gentoo host == | ||
− | If you have a web server runing on your host Gentoo system you will need to stop it for now. Later you can change the ports Zimbra will listen on and run your host's web server and your | + | If you have a web server runing on your host Gentoo system you will need to stop it for now. Later you can change the ports Zimbra will listen on and run your host's web server and your Zimbra web server on the same machine. |
− | :<tt># /etc/ | + | :<tt># /etc/init.d/apache2 stop</tt> |
− | :<tt># rc-update delete | + | :<tt># rc-update delete apache2</tt> |
== Installing Zimbra in a Gentoo chroot == | == Installing Zimbra in a Gentoo chroot == | ||
Line 15: | Line 15: | ||
'''Emerge debootstrap''' | '''Emerge debootstrap''' | ||
− | |||
:<tt># emerge debootstrap</tt> | :<tt># emerge debootstrap</tt> | ||
Line 24: | Line 23: | ||
'''Run debootstrap''' | '''Run debootstrap''' | ||
− | :<tt># debootstrap | + | :<tt># debootstrap --arch i386 etch /zimbra http://ftp.debian.org/debian</tt> |
− | + | We are assuming the i386 architecture. Feel free to try others but only i386 has been tested. | |
− | |||
'''Mount proc, dev and sys''' | '''Mount proc, dev and sys''' | ||
:<tt># mount -o bind /proc /zimbra/proc</tt> | :<tt># mount -o bind /proc /zimbra/proc</tt> | ||
− | |||
:<tt># mount -o bind /dev /zimbra/dev</tt> | :<tt># mount -o bind /dev /zimbra/dev</tt> | ||
+ | :<tt># mount -o bind /dev/shm /zimbra/dev/shm</tt> | ||
:<tt># mount -o bind /dev/pts /zimbra/dev/pts</tt> | :<tt># mount -o bind /dev/pts /zimbra/dev/pts</tt> | ||
− | :<tt># mount -o bind / | + | :<tt># mount -o bind /sys /zimbra/sys</tt> |
'''Chroot to the debian environment''' | '''Chroot to the debian environment''' | ||
− | :<tt># chroot /zimbra</tt> | + | :<tt># chroot /zimbra /bin/bash</tt> |
Line 47: | Line 45: | ||
'''Adjust your hosts and hostname files''' | '''Adjust your hosts and hostname files''' | ||
:<tt># nano -w /etc/hosts</tt> | :<tt># nano -w /etc/hosts</tt> | ||
+ | It should look something like this: | ||
+ | <tt><pre> | ||
+ | 111.222.333.444 hostname.example.com hostname | ||
+ | 127.0.0.1 localhost.localdomain localhost | ||
+ | </pre></tt> | ||
:<tt># nano -w /etc/hostname</tt> | :<tt># nano -w /etc/hostname</tt> | ||
− | + | This one should only contain your hostname. | |
− | |||
− | |||
− | |||
Line 66: | Line 66: | ||
'''Install some packages that we will need''' | '''Install some packages that we will need''' | ||
− | :<tt># apt-get install | + | :<tt># apt-get install ssh wget sudo libidn11 curl fetchmail libgmp3c2 libxml2 libstdc++6 openssl file perl libexpat1 postgrey libperl5.8 psmisc libpcre3 libltdl3</tt> |
'''Get the zimbra debian package and untar the archive''' | '''Get the zimbra debian package and untar the archive''' | ||
− | :<tt># | + | :<tt># cd ~</tt> |
− | :<tt># wget http://files.zimbra.com/downloads/ | + | :<tt># wget http://files.zimbra.com/downloads/5.0.9_GA/zcs-5.0.9_GA_2533.DEBIAN4.0.20080815215219.tgz</tt> |
− | :<tt># tar -xvzf zcs- | + | :<tt># tar -xvzf zcs-5.0.9_GA_2533.DEBIAN4.0.20080815215219.tgz</tt> |
'''Run install script in the newly created zcs directory''' | '''Run install script in the newly created zcs directory''' | ||
− | :<tt># cd zcs</tt> | + | :<tt># cd zcs-5.0.9_GA_2533.DEBIAN4.0.20080815215219</tt> |
:<tt># ./install.sh</tt> | :<tt># ./install.sh</tt> | ||
Line 82: | Line 82: | ||
− | '''Configure sshd to run on a different port | + | '''Configure sshd to run on a different port''' |
+ | |||
+ | ''(This is basically copied from the Zimbra forums at http://www.zimbra.com/forums/installation/9792-zimbra-gentoo-additional-info.html)'' | ||
− | sshd running on the Gentoo host | + | sshd running on the Gentoo host conflicts with a service that Zimbra runs. It will hinder Zimbra's ability to monitor queues from the management console. So let's fix it: |
:<tt># nano -w /etc/ssh/sshd_config </tt> | :<tt># nano -w /etc/ssh/sshd_config </tt> | ||
Line 94: | Line 96: | ||
and change it to: | and change it to: | ||
− | :<tt>port | + | :<tt>port 60022</tt> |
'''Start sshd''' | '''Start sshd''' | ||
− | :<tt># /etc/init.d/ | + | :<tt># /etc/init.d/ssh start</tt> |
− | ''' | + | '''Tell Zimbra to run sshd on port 60022''' |
:<tt># su - zimbra</tt> | :<tt># su - zimbra</tt> | ||
− | :<tt>$ | + | :<tt>$ zmprov ms MAIL.DOMAIN.COM zimbraRemoteManagementPort 60022</tt> |
+ | substitute MAIL.DOMAIN.COM with the fqdn of your host name | ||
+ | |||
+ | |||
+ | '''Build and deploy new ssh keys''' | ||
+ | This wasn't needed with version 5.0.8, but if you're using an older version perhaps you'll need it. | ||
+ | :<tt>$ /opt/zimbra/bin/zmsshkeygen</tt> | ||
+ | :<tt>$ /opt/zimbra/bin/zmupdateauthkeys</tt> | ||
+ | |||
+ | |||
+ | '''Test your Zimbra install''' | ||
+ | :<tt>$ /etc/init.d/zimbra start</tt> | ||
== Creating the init scripts == | == Creating the init scripts == | ||
− | It would be nice to get | + | It would be nice to get Zimbra to start at boot in the default run level. This requires an init script. |
− | |||
'''Exit chroot and create the gentoo init.d script''' | '''Exit chroot and create the gentoo init.d script''' | ||
Line 117: | Line 129: | ||
− | + | '''Make the script executable''' | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | '''Make the | ||
:<tt># chmod +x /etc/init.d/zimbra</tt> | :<tt># chmod +x /etc/init.d/zimbra</tt> | ||
− | |||
− | |||
Line 145: | Line 143: | ||
Now you should have a functioning Zimbra system installed in a chroot that you can manage from the host gentoo | Now you should have a functioning Zimbra system installed in a chroot that you can manage from the host gentoo | ||
− | system at boot or otherwise. If you were running a web server on your host gentoo system you will need to configure Zimbra to listen on different port for web and ssl (try 81 and 1443). Search the zimbra forums there is some documentation for this | + | system at boot or otherwise. If you were running a web server on your host gentoo system you will need to configure Zimbra to listen on different port for web and ssl (try 81 and 1443). Search the zimbra forums there is some documentation for this already in place. You will then be able to cofigure a named based vitual host to link from you gentoo hosted site to zimbra. |
== Script: /etc/init.d/zimbra == | == Script: /etc/init.d/zimbra == | ||
Line 162: | Line 160: | ||
ebegin "Starting Zimbra in chroot environment" | ebegin "Starting Zimbra in chroot environment" | ||
− | mount -o bind /proc /zimbra/proc | + | # Mount the dirs |
− | mount -o bind /dev /zimbra/dev | + | mount -o bind /proc /zimbra/proc > /dev/null |
− | mount -o bind /dev/shm /zimbra/dev/shm | + | mount -o bind /dev /zimbra/dev > /dev/null |
− | mount -o bind /dev/pts /zimbra/dev/pts | + | mount -o bind /dev/shm /zimbra/dev/shm > /dev/null |
− | mount -o bind | + | mount -o bind /dev/pts /zimbra/dev/pts > /dev/null |
+ | mount -o bind /sys /zimbra/sys > /dev/null | ||
− | chroot /zimbra / | + | # Start the services in chroot |
+ | chroot /zimbra /etc/init.d/sysklogd start | ||
+ | chroot /zimbra /etc/init.d/cron start | ||
+ | chroot /zimbra /etc/init.d/ssh start | ||
+ | chroot /zimbra /etc/init.d/postgrey start | ||
+ | chroot /zimbra /etc/init.d/zimbra start | ||
eend $? "Errors were encountered while starting Zimbra in chroot environment" | eend $? "Errors were encountered while starting Zimbra in chroot environment" | ||
Line 178: | Line 182: | ||
ebegin "Stopping Zimbra in chroot environment" | ebegin "Stopping Zimbra in chroot environment" | ||
− | chroot /zimbra / | + | # Stop all the services in chroot |
+ | chroot /zimbra /etc/init.d/zimbra stop | ||
+ | chroot /zimbra /etc/init.d/postgrey stop | ||
+ | chroot /zimbra /etc/init.d/ssh stop | ||
+ | chroot /zimbra /etc/init.d/cron stop | ||
+ | chroot /zimbra /etc/init.d/sysklogd stop | ||
− | umount -f /zimbra/ | + | |
− | umount -f /zimbra/dev | + | # Unmount the dirs |
− | umount -f /zimbra/dev/ | + | umount -f /zimbra/dev/shm > /dev/null |
− | umount -f /zimbra/dev/ | + | umount -f /zimbra/dev/pts > /dev/null |
− | umount -f /zimbra/ | + | umount -f /zimbra/sys > /dev/null |
+ | umount -f /zimbra/proc > /dev/null | ||
+ | umount -f /zimbra/dev > /dev/null | ||
eend $? "Errors were encountered while stopping Zimbra in chroot environment" | eend $? "Errors were encountered while stopping Zimbra in chroot environment" | ||
Line 191: | Line 202: | ||
</pre> | </pre> | ||
− | == Script: | + | == Script: for account migration from qmail+vpopmail to zimbra == |
<pre> | <pre> | ||
− | #!/bin/ | + | #!/usr/bin/php |
− | + | // http://wiki.zimbra.com/index.php?title=Password_Migration | |
− | + | // Modified migration script for gentoo+qmail+vpopmail | |
− | + | // | |
− | |||
− | |||
+ | |||
+ | <?php | ||
+ | ///////////////////////////////////////////////////////// | ||
+ | |||
+ | $user="user"; | ||
+ | $pass="password"; | ||
+ | $db="vpopmail"; | ||
+ | $table_mbox="vpopmail"; | ||
+ | $file="exported.sh"; | ||
+ | |||
+ | ///////////////////////////////////////////////////////// | ||
+ | echo "This script generates a bash script called: $file | ||
+ | The script contains the commands to re-create the mail accounts on zimbra server.\n\n | ||
+ | "; | ||
+ | |||
+ | $mydb = mysql_connect('localhost',$user, $pass) or die ('Error connecting to server'); | ||
+ | mysql_select_db($db); | ||
+ | mysql_query("SET CHARACTER SET utf8"); | ||
+ | mysql_query("SET NAMES utf8"); | ||
+ | |||
+ | $query = "SELECT pw_name,pw_domain,pw_passwd | ||
+ | FROM $table_mbox"; | ||
+ | $dane = mysql_query($query) or die ('Error during query for '.mysql_error()); | ||
+ | |||
+ | echo "Writing to $file ...\n"; | ||
+ | $fh = fopen($file, "w"); | ||
+ | $sp = '@'; | ||
+ | fwrite($fh, "#!/bin/sh -x\n\n"); | ||
+ | |||
+ | while ($row = mysql_fetch_array($dane, MYSQL_NUM)) | ||
+ | { | ||
+ | $data_mbox = "zmprov ca ".$row[0]."".$sp."".$row[1]." dsfs123hsdyfgbsdgfbsd displayName '".$row[0]."'\n"; | ||
+ | $data_mbox .= "zmprov ma ".$row[0]."".$sp."".$row[1]." userPassword '{crypt}".$row[2]."'"."\n"; | ||
+ | fwrite($fh, $data_mbox); | ||
+ | } | ||
+ | echo "Done."; | ||
</pre> | </pre> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | </ | + | Instructions for adding postgrey are found here: http://wiki.zimbra.com/index.php?title=Improving_Anti-spam_system |
+ | You might have to repeat postgrey adding at every upgrade so you might want to think twice about having it. If you don't, just | ||
+ | remove the two lines with postgrey in the init script. However, I highly recommend postgrey as it's really very efficient. Doesn't | ||
+ | cost as much processor power as other measures and it catches alot of spam. A good ''first sentry'' imhop. | ||
+ | |||
+ | About tweaking; I found the yahoo search bar pretty annoying and it's easily removed, persistent over upgrades: | ||
+ | :<tt> zmprov mc default zimbraFeatureWebSearchEnabled FALSE </tt> | ||
+ | I am still running my old apache so I had to change some ports: | ||
+ | :<tt> zmprov ms MAIL.DOMAIN.COM zimbraMailPort 8888 zimbraMailSSLPort 8889 </tt> | ||
+ | If you, like me, like to use https: | ||
+ | :<tt>http://wiki.zimbra.com/index.php?title=CLI_zmtlsctl_to_set_Web_Server_Mode</tt> | ||
+ | Of course, you then access your zimbra installation like so: | ||
+ | https://MAIL.DOMAIN.COM:8889 | ||
+ | these and many other tweaks can be found in the forums. | ||
==Building Zimbra from source on Gentoo== | ==Building Zimbra from source on Gentoo== | ||
''(needs to be documented)'' | ''(needs to be documented)'' | ||
+ | |||
+ | {{Article_Footer|ZCS 5.0.9|11/13/2006}} | ||
[[Category:Gentoo]] | [[Category:Gentoo]] | ||
[[Category:Installation]] | [[Category:Installation]] | ||
[[Category:Build]] | [[Category:Build]] |
Latest revision as of 17:08, 24 March 2015
Article Information |
---|
This article applies to the following ZCS versions. |
Here's a howto that will get Zimbra going on a Gentoo install. This method basically leverages debootstrap to get a bare debain sarge install in a chroot environment. The open source zimbra 5.0.9 package for Debian can then be installed. This is working on Gentoo 2008.0 kernel 2.6.25-gentoo-r7. But you shouldn't have any issues running it on recent versions. At first this may seem like extra work and a waste of resources, but to the contrary running Zimbra in a chroot is a pretty good idea. People have been hosting chroot jails on *BSD's to run various internet services for quite some time. This can add a level of protection for the host system. I.e. if the unthinkable happens and an attacker does find a way to gain root through the host services on your Zimbra instance, (s)he will only have access to the chroot environment.
Stopping Apache on the Gentoo host
If you have a web server runing on your host Gentoo system you will need to stop it for now. Later you can change the ports Zimbra will listen on and run your host's web server and your Zimbra web server on the same machine.
- # /etc/init.d/apache2 stop
- # rc-update delete apache2
Installing Zimbra in a Gentoo chroot
(Some of this was taken from http://www.elfenbeinturm.cc/2006/07/28/zimbra-on-gentoo/)
Emerge debootstrap
- # emerge debootstrap
Create the chroot environment
- # mkdir /zimbra
Run debootstrap
- # debootstrap --arch i386 etch /zimbra http://ftp.debian.org/debian
We are assuming the i386 architecture. Feel free to try others but only i386 has been tested.
Mount proc, dev and sys
- # mount -o bind /proc /zimbra/proc
- # mount -o bind /dev /zimbra/dev
- # mount -o bind /dev/shm /zimbra/dev/shm
- # mount -o bind /dev/pts /zimbra/dev/pts
- # mount -o bind /sys /zimbra/sys
Chroot to the debian environment
- # chroot /zimbra /bin/bash
Set a root password
- # passwd
Adjust your hosts and hostname files
- # nano -w /etc/hosts
It should look something like this:
111.222.333.444 hostname.example.com hostname 127.0.0.1 localhost.localdomain localhost
- # nano -w /etc/hostname
This one should only contain your hostname.
Tell apt where to get all the repositories
This will execute an ncurses menu prompting you to choose a debian mirror pick http or ftp and select a (hopefully) fast mirror:
- # apt-setup
Update the package listing
- # apt-get update
Install some packages that we will need
- # apt-get install ssh wget sudo libidn11 curl fetchmail libgmp3c2 libxml2 libstdc++6 openssl file perl libexpat1 postgrey libperl5.8 psmisc libpcre3 libltdl3
Get the zimbra debian package and untar the archive
- # cd ~
- # wget http://files.zimbra.com/downloads/5.0.9_GA/zcs-5.0.9_GA_2533.DEBIAN4.0.20080815215219.tgz
- # tar -xvzf zcs-5.0.9_GA_2533.DEBIAN4.0.20080815215219.tgz
Run install script in the newly created zcs directory
- # cd zcs-5.0.9_GA_2533.DEBIAN4.0.20080815215219
- # ./install.sh
Follow the instructions. See the Zimbra documentation for help.
Configure sshd to run on a different port
(This is basically copied from the Zimbra forums at http://www.zimbra.com/forums/installation/9792-zimbra-gentoo-additional-info.html)
sshd running on the Gentoo host conflicts with a service that Zimbra runs. It will hinder Zimbra's ability to monitor queues from the management console. So let's fix it:
- # nano -w /etc/ssh/sshd_config
Find the line that reads:
- port 22
and change it to:
- port 60022
Start sshd
- # /etc/init.d/ssh start
Tell Zimbra to run sshd on port 60022
- # su - zimbra
- $ zmprov ms MAIL.DOMAIN.COM zimbraRemoteManagementPort 60022
substitute MAIL.DOMAIN.COM with the fqdn of your host name
Build and deploy new ssh keys
This wasn't needed with version 5.0.8, but if you're using an older version perhaps you'll need it.
- $ /opt/zimbra/bin/zmsshkeygen
- $ /opt/zimbra/bin/zmupdateauthkeys
Test your Zimbra install
- $ /etc/init.d/zimbra start
Creating the init scripts
It would be nice to get Zimbra to start at boot in the default run level. This requires an init script.
Exit chroot and create the gentoo init.d script
- $ exit && exit
- # nano -w /etc/init.d/zimbra
- append init.d script from below
Make the script executable
- # chmod +x /etc/init.d/zimbra
Test the init script
- # /etc/init.d/zimbra stop
- # /etc/init.d/zimbra start
Add it to the default run level
- # rc-update add zimbra default
Now you should have a functioning Zimbra system installed in a chroot that you can manage from the host gentoo
system at boot or otherwise. If you were running a web server on your host gentoo system you will need to configure Zimbra to listen on different port for web and ssl (try 81 and 1443). Search the zimbra forums there is some documentation for this already in place. You will then be able to cofigure a named based vitual host to link from you gentoo hosted site to zimbra.
Script: /etc/init.d/zimbra
#!/sbin/runscript depend() { need net after portmap after iptables after dnsmasq } start() { ebegin "Starting Zimbra in chroot environment" # Mount the dirs mount -o bind /proc /zimbra/proc > /dev/null mount -o bind /dev /zimbra/dev > /dev/null mount -o bind /dev/shm /zimbra/dev/shm > /dev/null mount -o bind /dev/pts /zimbra/dev/pts > /dev/null mount -o bind /sys /zimbra/sys > /dev/null # Start the services in chroot chroot /zimbra /etc/init.d/sysklogd start chroot /zimbra /etc/init.d/cron start chroot /zimbra /etc/init.d/ssh start chroot /zimbra /etc/init.d/postgrey start chroot /zimbra /etc/init.d/zimbra start eend $? "Errors were encountered while starting Zimbra in chroot environment" } stop() { ebegin "Stopping Zimbra in chroot environment" # Stop all the services in chroot chroot /zimbra /etc/init.d/zimbra stop chroot /zimbra /etc/init.d/postgrey stop chroot /zimbra /etc/init.d/ssh stop chroot /zimbra /etc/init.d/cron stop chroot /zimbra /etc/init.d/sysklogd stop # Unmount the dirs umount -f /zimbra/dev/shm > /dev/null umount -f /zimbra/dev/pts > /dev/null umount -f /zimbra/sys > /dev/null umount -f /zimbra/proc > /dev/null umount -f /zimbra/dev > /dev/null eend $? "Errors were encountered while stopping Zimbra in chroot environment" }
Script: for account migration from qmail+vpopmail to zimbra
#!/usr/bin/php // http://wiki.zimbra.com/index.php?title=Password_Migration // Modified migration script for gentoo+qmail+vpopmail // <?php ///////////////////////////////////////////////////////// $user="user"; $pass="password"; $db="vpopmail"; $table_mbox="vpopmail"; $file="exported.sh"; ///////////////////////////////////////////////////////// echo "This script generates a bash script called: $file The script contains the commands to re-create the mail accounts on zimbra server.\n\n "; $mydb = mysql_connect('localhost',$user, $pass) or die ('Error connecting to server'); mysql_select_db($db); mysql_query("SET CHARACTER SET utf8"); mysql_query("SET NAMES utf8"); $query = "SELECT pw_name,pw_domain,pw_passwd FROM $table_mbox"; $dane = mysql_query($query) or die ('Error during query for '.mysql_error()); echo "Writing to $file ...\n"; $fh = fopen($file, "w"); $sp = '@'; fwrite($fh, "#!/bin/sh -x\n\n"); while ($row = mysql_fetch_array($dane, MYSQL_NUM)) { $data_mbox = "zmprov ca ".$row[0]."".$sp."".$row[1]." dsfs123hsdyfgbsdgfbsd displayName '".$row[0]."'\n"; $data_mbox .= "zmprov ma ".$row[0]."".$sp."".$row[1]." userPassword '{crypt}".$row[2]."'"."\n"; fwrite($fh, $data_mbox); } echo "Done.";
Instructions for adding postgrey are found here: http://wiki.zimbra.com/index.php?title=Improving_Anti-spam_system You might have to repeat postgrey adding at every upgrade so you might want to think twice about having it. If you don't, just remove the two lines with postgrey in the init script. However, I highly recommend postgrey as it's really very efficient. Doesn't cost as much processor power as other measures and it catches alot of spam. A good first sentry imhop.
About tweaking; I found the yahoo search bar pretty annoying and it's easily removed, persistent over upgrades:
- zmprov mc default zimbraFeatureWebSearchEnabled FALSE
I am still running my old apache so I had to change some ports:
- zmprov ms MAIL.DOMAIN.COM zimbraMailPort 8888 zimbraMailSSLPort 8889
If you, like me, like to use https:
Of course, you then access your zimbra installation like so: https://MAIL.DOMAIN.COM:8889 these and many other tweaks can be found in the forums.
Building Zimbra from source on Gentoo
(needs to be documented)