How to setup a basic instance of daiquiri

This is meant to be a step by step guide to setup a new instance of daiquiri. It is tested with Ubuntu 14.04, debian 8 and Scientific Linux 6.6 and 7.1. Other distributions might differ. For the deployment of an existing daiquiri web application on a new server, follow only the first steps until Initialising Project.

Install prerequisites and prepare server

As usual it is the best idea to install as much as possible using the distribution packaging system. Instalation of the different software might require root privilages and you might be required to use sudo command.

# For RHEL/CentOS/SL
yum install httpd mysql git php php-devel php-mysql php-gd php-pear

# debian/Ubuntu
apt-get install apache2 mysql-server git php5 php5-dev php5-mysql php5-gd

On debian/Ubuntu mod rewrite needs to enabled manually.

a2enmod rewrite

depending on your particular case, you might want to change the following php-seetings.

max_execution_time = 600  # for the download of larger files
post_max_size = 32M       # if you want to upload files via wordpress
upload_max_filesize = 32M

On debian/Ubuntu this needs to be done in /etc/php5/apache2/php.ini and and on RHEL/CentOS/SL in /etc/php.ini.

Obtain the daiquiri and the daiquiri-app repository

The preferred way of getting the Daiquiri repositories is by cloning them from github:

git clone ssh://git@github.com:aipescience/daiquiri.git
git clone ssh://git@github.com:aipescience/daiquiri-app.git

Although not necessary, it is recommended to clone both repositories next to each other in one directory. Preferably /srv/ which we will use for the remaining manual.

Create directories

Daiquiri requires several directories which need to be writable by the web server. Again, we recommend to put these under '/srv/', but any other path which is not exposed via the web server (under your Apache DocumentRoot or Aliases) is ok. For Ubuntu the AppArmor rules might ned to be adjusted, to make it possible for MySQL to write in the download directory. In RHEL/CentOS/SL selinux should be set to permissive.

mkdir -p /srv/captcha \
         /srv/download \
         /srv/navigation \
         /srv/log

# RHEL/CentOS/SL
chown -R apache:apache /srv/captcha \
                       /srv/download \
                       /srv/navigation \
                       /srv/log

# Ubuntu/debian
chown -R www-data:www-data /srv/captcha \
                           /srv/download \
                           /srv/navigation \
                           /srv/log

Configure the init.php file of the application

All options in the configuration file are described on a different page.

In any case, you need to copy the default file located in your daiquiri-app directory:

cp default.init.php init.php

Create application.ini

The daiquiri application needs an configuration file, which is created using

./init.php -a

Note that in order to run init.php from the command line you will need to have installed the PHP Command Line Interface. In debian systems you can install the php5-cli package.

The daiquiri application also needs some softlinks to work. They can be automatically created by running

./init.php -l

Configure virtual host for Apache

The virtual host configuration can be automatically generated using:

./init.php -v

inside the application directory.

You can also change your virtual host configuration file manually. Typical location of the default configuration file used by Apache is /etc/apache2/sites-enabled/000-default.conf.

A minimal virtual host configuration of a Daiquiri application which runs in the root of the webserver looks like this:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName www.example.com

    XSendFile on
    XSendFilePath /srv/download
    XSendFilePath /store/daiquiri/files/

    #SetEnv APPLICATION_ENV development

    DocumentRoot "/srv/daiquiri-app/public"
    <Directory "/srv/daiquiri-app/public">
        Options +FollowSymLinks -Indexes -MultiViews
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

An additional installation of Apache mod mod_xsendfile might be needed. Source codes and installation guid can be found at this page.

When you comment out SetEnv APPLICATION_ENV development the application is in debug mode, and application errors will be displayed in a verbose way. This is obviously not recommended in a production environment. If you run Daiquiri under an Alias the virtual host configuration should look like this:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName www.example.com

    DocumentRoot /var/www/html/

    # ...

    XSendFile on
    XSendFilePath /srv/download
    XSendFilePath /store/daiquiri/files/

    #SetEnv APPLICATION_ENV development

    DocumentRoot "/srv/daiquiri-app/public"
    <Directory "/srv/daiquiri-app/public">
        Options +FollowSymLinks -Indexes -MultiViews
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

Please add the lines you need to your apache configuration and restart the server.

service httpd restart    # RHEL/CentOS/SL
service apache2 restart  # Ubuntu/debian

Configure MySQL database

As for the virtual host configuration, the commands to create users in MySQL can also be automatically generated.

To generate MySQL commands change into application directory and run:

./init.php -u

To clear the database from the user created in this way the output of

./init.php -c

can be used.

Settings, including the user name and password, can be changed directly in the init.php file.

Daiquiri needs two database adapters, a web adapter which connects to the web database which holds all the internal tables of Daiquiri, and a user adapter adapter which connects to the science database for querying and to the private user databases. These two adapters do not need to be located on the same machine, but can be. They can also use the same database user.

Here we use the example users from the default.init.php file. Please change at least the passwords in the init file. The database users need to be created on the respective database server:

CREATE USER 'daiquiri_web'@'localhost' IDENTIFIED BY 'daiquiri_web';
GRANT ALL PRIVILEGES ON `daiquiri_web`.* to 'daiquiri_web'@'localhost';

CREATE USER 'daiquiri_user'@'localhost' IDENTIFIED BY 'daiquiri_user';
GRANT ALL PRIVILEGES ON `daiquiri_user_%`.* to 'daiquiri_user'@'localhost';
GRANT SELECT ON `mysql`.`func` to 'daiquiri_user'@'localhost';

If the database runs on a different machine than the web application, substitute localhost with the ip of the web application server.

If you intend to use the query queue mysql plugin with Daiquiri, you also need to grand permissions to

GRANT SELECT ON `mysql`.`qqueue_queues` to `daiquiri_user`@`localhost`;
GRANT SELECT ON `mysql`.`qqueue_usrGrps` to `daiquiri_user`@`localhost`;
GRANT SELECT ON `mysql`.`qqueue_jobs` to `daiquiri_user`@`localhost`;
GRANT SELECT, UPDATE ON `mysql`.`qqueue_history` to `daiquiri_user`@`localhost`;

In addition, grant privileges on the different scientific databases you want to publish via the query interface:

GRANT SELECT, ALTER ON `DB`.* to `daiquiri_user`@`localhost`;

Run the init process

If everything is set up, the actual init process which creates the databases and tables can be triggered. This is done by calling:

./init.php -si # 's' for syncing the database, i.e. creating the database tables
               # 'i' for initializing the database with initial data