Installing ZendTo on CentOS

The aim of this document is to provide brief notes so that an experienced system administrator can install ZendTo on an existing CentOS server. This assumes a new server only to be used for ZendTo.

Install Packages

yum -y install sendmail sendmail-cf httpd mod_ssl mysql mysql-server elinks rpm-build vixie-cron crontabs logrotate yum-cron sendmail-cf
chkconfig mysqld on
chkconfig iptables off
chkconfig ip6tables off
chkconfig httpd on
service mysqld start
mysql_secure_installation

Set root password? [Y/n] y
New password:
Re-enter new password:

Remove anonymous users? [Y/n] y

Disallow root login remotely? [Y/n] y

Remove test database and access to it? [Y/n] y

Reload privilege tables now? [Y/n] y

rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
rpm -Uvh http://download1.rpmfusion.org/free/el/updates/testing/5/i386/rpmfusion-free-release-5-0.1.noarch.rpm 
rpm -Uvh http://download1.rpmfusion.org/nonfree/el/updates/testing/5/i386/rpmfusion-nonfree-release-5-0.1.noarch.rpm
rpm -Uvh http://dl.iuscommunity.org/pub/ius/stable/Redhat/5/i386/ius-release-1.0-8.ius.el5.noarch.rpm

These next 2 are not for CentOS 6:

yum remove 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
yum -y install libdbi lua-devel gettext lua ruby xorg-x11-fonts-Type1 perl-rrdtool rrdtool clamav clamav-db clamd
chkconfig clamd on
freshclam

Install ZendTo repository and packages

rpm -Uvh http://zend.to/files/zendto-repo.rpm
yum install zendto

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

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 317, should contain /opt/zendto/www between the quotes
HostnameLookups
on

Set Permissions For Virus Scanning

usermod -a -G apache clamav
usermod -a -G apache clam
chown clam /var/log/clamav/clamd.log
chgrp clamav /var/log/clamav /var/lib/clamav
chmod g+w /var/log/clamav /var/lib/clamav
Edit /etc/freshclam.conf to use the "DatabaseDirectory" "/var/lib/clamav".
freshclam
service clamd restart

Configure SELinux

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

Setup Mail

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.

If you make any changes, do

cd /etc/mail && make
service sendmail restart

If you still cannot get mail to be delivered correctly, I have written a minimal sendmail.mc file which will work perfectly well for most people. Just read the file to see what to change for your organisation.

Setup Database

ZendTo requires a small back-end database to store all its information. On CentOS you have to use MySQL as SQLite is not available for PHP on CentOS or RedHat.

MySQL

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:

# service mysqld start
# mysql
mysql> CREATE DATABASE zendto;
mysql> GRANT ALL PRIVILEGES ON zendto.* TO zendto@localhost
    IDENTIFIED by 'zendtopassword';
mysql> quit
where "zendtopassword" is a password of your own.
# mysql --user=zendto --password='zendtopassword' zendto < /opt/zendto/sql/zendto.MySQL

Setup php

This is all documented here.

Update /opt/zendto/config/preferences.php

Near the top of the file, find the setting for "SqlBackend" and change it to
define('SqlBackend', 'MySQL');
and set the MySQL settings as shown below:
  // Next 4 lines needed for MySQL operation
  'MySQLhost'            => 'localhost',
  'MySQLuser'            => 'zendto',
  'MySQLpassword'        => 'zendtopassword',
  'MySQLdb'              => 'zendto',

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

Reboot to ensure all services are stopped and started as necessary.

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/httpd.

If you get lots of warnings about "strftime()" then setup the timezone correctly.

Setup Logging

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

Ignore any "PHP Notice" output from that.

Add a User

Add a user such as this example user:

cd /opt/zendto/bin
export ZENDTOPREFS=/opt/zendto/config/preferences.php
./adduser.php jdoe zendtopass2011 johndoe@mycompany.com 'J Doe' 'My Company' 100000000

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 and there is more help available.