FreeBSD Setup

This guide will explain how to install ZendTo on FreeBSD systems.
NOTE: The guide assumes you already have Apache and PHP installed. If you don't have them installed, please follow:

http://www.freebsdmadeeasy.com/tutor...on-freebsd.php for Apache.
http://www.freebsdmadeeasy.com/tutor...eb-hosting.php for PHP.

Overview:

Step 1: Download the ZendTo tarball
Code:
# cd /root/
# fetch http://zend.to/files/ZendTo-4.08-4.tgz (or the latest)
# tar -xzf ZendTo-4.08-4.tgz
Step 2: Setup the ZendTo directories:

Web directory:
Code:
# mkdir /opt
# mv /root/ZendTo-4.08-4 /opt/zendto 
# chown -R www:www /opt/zendto
Data directory:
Code:
# mkdir /var/zendto
# mkdir /var/zendto/dropoffs
# mkdir /var/zendto/incoming
# chown -R www:www /var/zendto
Step 3: Configure Apache
(This step assumes Apache is already installed. If you haven't installed Apache and PHP, please refer to the earlier links)
Code:
# cd /usr/local/etc/apache22/Includes
# touch zendto.conf
We can either configure ZendTo as the root Apache directory, or as an Alias.

If you want to run ZendTo as an Alias (ex. www.yoursite.com/zendto) follow these steps. Else, skip ahead.
Edit /usr/local/etc/apache22/Includes/zendto.conf
Code:
Alias /zendto /opt/zendto/www
<Directory /opt/zendto/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all

    # Add this part only if you want to force HTTPS
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</Directory>
Uncomment/add this line in /usr/local/etc/apache22/httpd.conf
Code:
Include etc/apache22/Includes/*.conf
The header.tpl template in ZendTo doesn't place nice with Alias directories. Clicking the "Home" button takes the user back to the '/' (top-level) directory. Since you will not running ZendTo at root, we'll need to make a two-line change to header.tpl.

Code:
# cd /opt/zendto/templates
# cp header.tpl header.tpl.backup
Edit /opt/zendto/templates/header.tpl
Code:
On line 47 and 50, change:
<a href="/">
to:
<a href="index.php">

If you want to run ZendTo on the DocumentRoot (ex. www.yoursite.com), follow these steps. Else, follow the previous steps.

Edit /usr/local/etc/apache22/Includes/zendto.conf
Code:
<Directory /opt/zendto/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all

    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</Directory>
Edit /usr/local/etc/apache22/httpd.conf
Code:
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/opt/zendto/www"
Include etc/apache22/Includes/*.conf
If you're running an SSL-enabled Apache site also edit /usr/local/etc/apache22/extra/httpd-ssl.conf
Code:
#   General setup for the virtual host
DocumentRoot "/opt/zendto/www"
Step 4: Install & Configure PHP Modules

(This step assumes PHP is already installed. If you haven't installed PHP, please refer to the earlier link)

Code:
cd /usr/ports/lang/php5-extensions/ && make install clean
Select the following options
[x] BCMATH
[x] CURL
[x] GD
[x] IMAP
[x] LDAP
[x] MBSTRING
[x] MCRYPT
[x] MYSQL
[x] PDO
[x] PDO_SQLITE
[x] SESSION
[x] SOAP
[x] SQLITE
[x] XMLRPC

cd /usr/ports/www/pecl-APC/ && make install clean
cd /usr/ports/databases/pecl-memcache/ && make install clean
Note: this list was compiled from the Zend.to PHP extensions list here: http://zend.to/phpfix.php, as well as through trial-and-error.

You'll need to add some variables to the system's php.ini file for ZendTo to work properly.
Code:
# cd /usr/local/etc/
# cp php.ini php.ini.backup

if php.ini doesn't exist, then:
# cp php.ini-production php.ini
Edit php.ini and add/edit the following variables in red:
Code:
...
* error_reporting = E_ALL & ~E_DEPRECATED & ~E_NOTICE
* max_execution_time = 7200
* max_input_time = 7200
* memory_limit = 300M
* display_errors = On
* post_max_size = 50000M
* upload_tmp_dir = /var/zendto/incoming
* upload_max_filesize = 50G
* max_file_uploads = 200 This setting does not apply to CentOS
* apc.rfc1867 = on
* apc.max_file_size = 50G
* apc.slam_defense = off
* Set "date.timezone" to the relevant timezone you are in, for example "Europe/London".
...
Note: this list of php.ini variables was lifted from here: http://zend.to/phpini.php


Step 5: Configure ZendTo:

All the settings for ZendTo are in the preferences.php file, which is normally found in /opt/zendto/config/preferences.php. Do not change values in this file unless you need to, and then only after carefully reading the comments in the file.

Edit /opt/zendto/config/preferences.php
Code:
Change the quota to something a little bigger:
(this is supposed to be a large-file replacement for E-mail, right?)

...
'defaultMyZendToQuota' => 1000000000, // 1GB 
...
Enable recaptcha for to prevent spam bots from using your site.  Go to https://www.google.com/recaptcha/admin/create, use a Gmail account, and generate a public/private key.

Edit /opt/zendto/config/preferences.php
Code:
Enter the keys respectively in preferences.php
...
  'recaptchaPublicKey'   => '',
  'recaptchaPrivateKey'  =>  '',
...
Now open zendto.conf and editing the following variables in red to reflect your organization.

Code:
# ee zendto.conf

...
ContactInfo = "Copyright &copy 2011"
Username = "Southampton Username"
NonLocalUsers = "non-Southampton users"
LocalUser = "a Southampton user"
OrganizationType = "the University"


# These are settings used in email messages
EmailSenderAddress = 'ZendTo <helpdesk@zend.to>'
UnknownRecipient = "One of the recipients"
VerifyEmailSubject = "[ZendTo] You are trying to drop-off some files"

# The %s in the next lines are replaced with the name of who picked it up
PickupEmailSubject = '[ZendTo] %s has picked up your drop-off!'
DropoffEmailSubject1 = '[ZendTo] %s has dropped off a file for you'

DropoffEmailSubject2 = '[ZendTo] %s has dropped off files for you'

ErrorWillNotSend = "You must be logged in as an Southampton user in order to drop-off a file for a non-Southampton user.<br />&nbsp;<br />Return to the ZendTo main menu to log in and then try again." 
...
Step 6: Enable virus scanning:

Install ClamAV
Code:
# cd /usr/ports/security/clamav/ && make install clean
Configure ClamAV clamd to start on startup:
Code:
# echo "clamav_clamd='YES'" >> /etc/rc.conf
# echo "clamav_freshclam_enable='YES'" >> /etc/rc.conf
Now we need to fix some permission issues. ClamAV by defaults runs under the user clamav, which won't be able to read the temporary files under ZendTo, which are owned by user www. We change ClamAV to run under user wwwinstead. To do this: (If someone knows of a better way to do this, please let me know)

Edit /usr/local/etc/clamd.conf
Code:
change:
User clamav
to: 
User www
Now because both clamav-clamd and clamav-freshclam both use the same directories (/var/run/clamav, /var/log/clamav), but will be running as separate users, we'll need to change the directory permissions.
Code:
# pw usermod www -G clamav
# chmod 775 /var/run/clamav
# chmow 775 /var/log/clamav
Start ClamAV
Code:
# /usr/local/etc/rc.d/clamav-freshclam start
# /usr/local/etc/rc.d/clamav-clam start
Edit the ClamAV variables in /opt/zendto/config/preferences.php
Code:
...
'clamdscan' => '/usr/local/bin/clamdscan --quiet',
...
# apachectl restart

Step 7: Optional. Enable IMAP authentication:

This sets up authentication against an IMAP server (so users can log in with their E-mail accounts credentials)

Edit /opt/zendto/config/preferences.php
Code:
//'authenticator' => 'Local',
  'authenticator' => 'IMAP',
  'authIMAPServer' => 'www.example.com:993/ssl/novalidate-cert',
  'authIMAPDomain' => '',
  'authIMAPOrganization' => 'example.com',
Now log in as user@example.com, and you'll be able authenticate to send files.

Note: The /ssl and /novalidate-cert options were lifted from here: http://php.net/manual/en/function.imap-open.php

Note: these instructions were lifted from here: http://zend.to/authentication.php

Step 8: Verify that everything works

Go to https://www.yoursite.com/zendto to see if it loads.

Check out the ZendTo Administration guide, create a user, and send some files around.

Your Zend.to instance is complete. If you want to know more about MyZendTo, the brother of ZendTo, and how to configure it, check out http://zend.to/documentation.php.

Written by: Jared Davenport <jared.davenport1 AT gmail DOT com>