Building Your Own Ubuntu ZendTo Server

Note: This document has been totally superceded by the installer which is available from the downloads page. The installer automates the entire process.


The aim of this document is to provide brief notes so that an experienced system administrator can install ZendTo on a pre-existing Ubuntu server. These are notes and not a full HOWTO document.

Install Packages — Ubuntu

apt-get install debhelper bison chrpath freetds-dev libcurl4-openssl-dev libedit-dev libgd2-xpm-dev libgmp3-dev libmhash-dev libpam0g-dev libpspell-dev librecode-dev libsasl2-dev libsnmp-dev libsqlite0-dev libt1-dev libtidy-dev re2c unixodbc-dev
apt-get -y install apache2-prefork-dev autoconf automake flex hardening-wrapper libapr1-dev libbz2-dev libdb-dev libenchant-dev libgcrypt11-dev libglib2.0-dev libicu-dev libmysqlclient-dev libpcre3-dev libpq-dev libsqlite3-dev libxmltok1-dev libxml2-dev libxslt1-dev quilt
apt-get -y install clamav clamav-daemon
apt-get -y install php5 php5-cli php5-sqlite php5-ldap php5-imap php-apc
apt-get -y install rrdtool

Install Packages — CentOS

rpm -e --allmatches gtk2 trousers ecryptfs-utils
yum -y install sendmail sendmail-cf
yum -y install httpd mod_ssl
yum -y install mysql mysql-server
chkconfig mysqld on
chkconfig iptables off
chkconfig ip6tables off
chkconfig httpd on

yum -y install elinks rpm-build
yum -y install vixie-cron crontabs logrotate yum-cron
elinks http://packages.sw.be/
Download from "clamav" dir: clamav clamav-db clamd
Download from "lua" dir: lua lua-devel
Download from "rrdtool" dir: lua-rrdtool perl-rrdtool rrdtool
yum -y install libdbi lua-devel gettext lua ruby xorg-x11-fonts-Type1
rpm -Uvh *rpm
freshclam
rm *rpm

rpm -Uvh http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
rpm -Uvh http://dl.iuscommunity.org/pub/ius/stable/Redhat/5/i386/ius-release-1.0-8.ius.el5.noarch.rpm
rpm --nodeps -e php php-cli php-common php-imap php-pdo php-ldap php-mysql
yum install php52-pear php52 php52-cli php52-common php52-devel php52-gd php52-mbstring php52-mcrypt php52-mysql php52-pdo php52-soap php52-xml php52-xmlrpc php52-bcmath php52-pecl-apc php52-pecl-memcache php52-ldap

Unpack ZendTo — Ubuntu

cd /opt
tar xzf /root/zendto.tgz
ln -s Zend* zendto

Unpack ZendTo — CentOS

rpm -Uvh zendto*.noarch.rpm

Build PHP

This only applies to x86_64 (or x64 64-bit) systems, don't do this step on 32-bit x86 systems as you will achieve nothing. PHP as shipped has a limit of 2 Gbytes on the size of any upload, and we need to work round that.

This is already documented here.

php.ini and apc.ini Settings

This is already documented here.

Apache Virtual Host — Ubuntu

cd /etc/apache2/sites-enabled
rm 000-default
cat <<EOF > 000-zendto
<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        HostnameLookups On

        DocumentRoot /opt/zendto/www
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /opt/zendto/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        LogLevel notice
        ErrorLog /var/log/apache2/error.log
        CustomLog /var/log/apache2/access.log combined
</VirtualHost>
EOF

Setup the secure SSL website if you need it. This is already documented here. Make sure the files ssl.conf, ssl.load and rewrite.load are linked from /etc/apache2/mods-available to /etc/apache2/mods-enabled.

Apache Virtual Host — CentOS

Edit /etc/httpd/conf/httpd.conf and set the following lines appropriately for your site:

ServerName
The name of your ZendTo website with ":80" added on the end
DocumentRoot
/opt/zendto/www
<Directory "">
Around line 307, should contain /opt/zendto/www between the quotes
HostnameLookups
on

Set Permissions — Ubuntu

usermod -a -G www-data clamav
cd /var
mkdir zendto zendto/dropoffs zendto/incoming zendto/rrd
touch zendto/zendto.log
chown www-data zendto/*
chgrp www-data zendto zendto/*
chmod g+w zendto
cd /opt/zendto
chmod -R a+rX .
chmod -R a+rx bin
chown -R www-data templates_c myzendto.templates_c cache
chgrp -R www-data templates_c myzendto.templates_c cache
chmod -R g+w templates_c myzendto.templates_c cache

Set Permissions — CentOS

usermod -a -G apache clamav

Configure Apparmor — Ubuntu only

Edit /etc/apparmor.d/local/usr.sbin.clamd and add this line (including the comma at the end:
/var/zendto/** r,

Configure SELinux — CentOS only

You need to do one of

  • Configure SELinux to allow clamd access to everything in and under /var/zendto, or
  • Disable SELinux altogether.
    Edit /etc/sysconfig/selinux and change the setting to
    SELINUX=disabled

Add Cron Jobs — Ubuntu only

export EDITOR=vi
crontab -e
Add these 3 lines at the end:
5 0 * * * /usr/bin/php /opt/zendto/sbin/cleanup.php /opt/zendto/config/preferences.php
2 10 * * * /usr/bin/php /opt/zendto/sbin/rrdInit.php /opt/zendto/config/preferences.php
2 12 * * * /usr/bin/php /opt/zendto/sbin/rrdUpdate.php /opt/zendto/config/preferences.php

Setup Mail — Ubuntu

You need to put your own settings into /etc/postfix/main.cf. The ones you need to change are:

  • myhostname — Your fully qualified hostname
  • mydestination — Put your fully qualified hostname first in the comma-separated list
  • relayhost — Your SMTP server or "smarthost". This must be configured to accept and deliver any mail from your ZendTo server, even if its "From" address is not in your domain

And put only your internet domain name into /etc/mailname. This file must only be 1 line.

Setup Mail — CentOS

You need to put your own settings into /etc/mail/sendmail.mc. The only change required is to remove and "dnl" from the start of the line that defines "SMART_HOST" and set the value to the fully qualified name of your SMTP server or "smarthost". This must be configured to accept and deliver any mail from your ZendTo server, even if its "From" address is not in your domain.

Then run the command

cd /etc/mail ; make
service sendmail restart
If that make command fails, install the sendmail-cf package with the command
yum -y install sendmail-cf

Setup Database

ZendTo requires a small back-end database to store all its information. On Ubuntu I strongly recommend you use SQLite as it is a lot simpler to use and requires no configuration at all. On CentOS you have to use MySQL as SQLite is not available for PHP on CentOS or RedHat.

MySQL — CentOS only

Setting up the MySQL database can be done by creating an empty database, importing the table layout and granting the proper permissions to the zendto user. Here is an example of that procedure:

# mysql
mysql> CREATE DATABASE zendto;
mysql> GRANT ALL PRIVILEGES ON zendto.* TO zendto@localhost
    IDENTIFIED by 'password';
mysql> quit

# mysql --user=zendto --password='password' zendto < /opt/zendto/sql/zendto.MySQL
  • 'password' is the master password for the zendto user. I strongly recommend that you replace this with a more secure password. Please remember that you will need to specify all the database connection details in /opt/zendto/www/preferences.php.
  • If you are upgrading from a previous version of ZendTo and the database has changed, just do the last "mysql" command given above. It will not delete anything, don't worry; it will just add any new tables necessary.

Reboot

And then try starting a web browser and going to http://your.site.here/about.php. That will trigger the creation of all the necessary database tables. Then try the website's home page at http://your.site.here.

If it doesn't work, check your Apache logs in /var/log/apache2 (Ubuntu) or /var/log/httpd (CentOS).

Setup Logging

cd /opt/zendto/sbin
php rrdInit.php /opt/zendto/config/preferences.php

Ignore any "PHP Notice" output from that.

Add a User

If you have got this far, well done!

Use the scripts in /opt/zendto/bin to add a new local user and list the users. All the scripts in there will show you their command-line syntax if you run them with no command-line parameters. It is worth setting ZENDTOPREFS as suggested.

If you can now log in, you need to go and configure /opt/zendto/config/preferences.php and then /opt/zendto/config/zendto.conf. Those 2 files are pretty well commented.