Installation

From MIDAS Wiki

Jump to: navigation, search

The current stable version of MIDAS is 2.8

Contents

Linux

This tutorial was written for Ubuntu 7.10 (gutsy) but should work with most recent versions of Ubuntu

  • Apache version 2
  • PostgreSQL version 8.2 or higher
  • ImageMagick version 6.0 and higher
  • PHP 5.2 or higher (json is required and available only in 5.2 otherwise check the section on how to install JSON)

Server Installation

  • WARNING: In some cases SELINUX is not allowing symlinks to a directory outside the document root
    • To disable SELINUX use the command: setenforce 0, a reboot may be required and security implications do exist.


  • Install necessary packages: imagemagick, xpdf, ffmpeg, mplayer, apache2, php5, libapache2-mod-php5, php5-gd and php5-pgsql
sudo apt-get install -y imagemagick xpdf ffmpeg mplayer apache2 php5 libapache2-mod-php5 php5-gd php5-pgsql
  • For additional functionality install: php5-curl and sendmail
sudo apt-get install -y php5-curl sendmail


  • Enable mod_rewrite for apache2:
 sudo ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load
  • Edit /etc/apache2/sites-enabled/000-default (default website configuration)
    • Note that the directory /var/www/Midas is the actual directory where the MIDAS source code is located. You should change accordingly.
 <Directory /var/www/Midas>
   Options Indexes FollowSymLinks MultiViews
   AllowOverride All
   Order allow,deny
   allow from all
  </Directory>
  • Change the maximum post size in PHP: /etc/php5/apache2/php.ini
 post_max_size = 2047M
 upload_max_filesize = 2047M
 memory_limit = 64M

Warning: 2048M or more will cause MANY versions of Apache to crash

  • Restart the apache2 server:
 sudo /etc/init.d/apache2 restart
  • If you run into a "could not reliably determine server's fully qualified domain name using 127.0 1.1 ..." error edit /etc/apache2/httpd.conf and add the following line and restart apache2 server:
 ServerName localhost
  • Install postgreSQL (there are known issues for Midas with Postgres 9, so use a version 8 install):
 sudo apt-get install postgresql

or can specify version 8.4 like

 sudo apt-get install postgresql-8.4

or

 yum install postgresql-server (CentOS)
  • Edit /etc/postgresql/8.3/main/pg_hba.conf (PostgreSQL version is 8.4 for Karmic Koala) and add the following line. WARNING: if a line like
 local all all ident sameuser

already exists replace it with the one below.

 local all all trust

You might also need to change the other security issues based on your system:

 host    all         all         127.0.0.1/32         trust
 host    all         all         ::1/128              trust
  • Restart PostGreSQL:
 sudo /etc/init.d/postgresql-8.3 restart

 sudo apt-get install phppgadmin
  • Optionally install JSON for PHP (if version < 5.2)
    • Install PECL json package.
 sudo pecl install json
    • You may need to install the php5 development tools to get necessary executables like phpize:
 sudo apt-get install php5-dev
    • Add json.ini file to /etc/php.d/ – This file is pretty simple. Simply add extension=json.so to this file and that will enable the extension.
    • Restart Apache – Not much more to add here. Without the restart, the extension won’t be loaded.

MIDAS Installation

See the appropriate section of Midas Server Installation


  • Create the database user: It's what you have choosen for Midas_DB_LOGIN when building Midas source. If you make a mistake, dropuser to undo your changes.
 sudo -u postgres createuser -U postgres -W -d -S -P Midas_DB_LOGIN
    • Enter the password for the new role Midas_DB_LOGIN (It's the password that has been set when building Midas source: Midas_DB_PASS)
    • Shall the new role be allowed to create more new roles? No
    • Enter password: type Midas_DB_PASS
  • Create the database table: It's what you have choosen for Midas_DB_NAME when building Midas source. If you make a mistake, dropdb to undo your changes.
    • If you encounter any errors when creating the table, try to create it using phppgamin
 sudo -u postgres createdb -U Midas_DB_LOGIN -W -E UNICODE Midas_DB_NAME
  • Using your favorite web browser go to
 Midas_SERVER_URL
  • If you encounter any permission issues on the default filters (Linux only; adjust for your system path)
sudo chmod +x /var/www/Midas/midas/filters/linux/32/*
sudo apt-get install antiword  # for word counting

Windows

MIDAS runs on a standard WAMP stack.

Server Installation

Note: Midas is currently tested on XAMMP 1.7. Be aware that there are known problems with later versions of XAMPP (connections between php and PostgreSQL over Apache), so prefer version 1.7.

  • Get XAMMP and install it with the default location.
  • Edit the xampp\apache\conf\httpd.conf and make sure that the following line is uncommented
 LoadModule rewrite_module modules/mod_rewrite.so
  • Change the maximum post size in PHP. Make these edits in php.ini. There are many php.ini files, load http://localhost/xampp/phpinfo.php and find the value for Loaded Configuration File, then use this php.ini listed to make your edits.
 post_max_size = 2G
 upload_max_filesize = 2G
 memory_limit = 64M

Warning: Putting 2048M on certain configurations (apache2/ubuntu) causes the server to fail to receive session requests!

Warning: Putting 2G on certain configurations (apache2/ubuntu 9.10) causes the server to fail to receive session requests!

Warning: Putting 2G may not work, in this case put 2047M

  • restart apache (you can restart apache through the xampp control panel, or if you installed apache as a service, through the services menu).
  • Make sure that the following fields in YourDrive:\YourXamppDirectory\apache\conf\httpd.conf look like this : (For example, my drive is C: and xampp is directly installed on C:)
 # 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 "C:/xampp/htdocs"

and

 #
 # This should be changed to whatever you set DocumentRoot to.
 #
 <Directory "C:/xampp/htdocs">

PostGreSQL Installation

Install the Postgres 8.4 PostGreSQL

  • Launch pgAdmin III (should be available from PostgreSQL item of Windows Start menu)
    • Connect to your server, the password is the password you set when you installed pgAdmin III.
    • Create a new role midas
      • Right click on Login Roles -> New Login Role
        • In the Role priviligies tab make sure that the "Can create role" box is unchecked
        • In the properties tab
    Role name : midas
    Password : yourpassword
    Password (again) : yourpassword 
    • Create a new database midas
      • Right click on Databases -> New database
   Name : midas
   Owner : midas
   Encoding : UTF-8
  • Edit Midas/midas/config/config.php
 // Password for PostGres database access
 $MIDAS_PG_DB_PASS = 'password you set for the user midas';

Installing the MIDAS Server and First Time Use

See the appropriate section of Midas Server Installation

  • Using your favorite web browser go to
 http://yourmidasserver/Midas
  • The default administrator login pass:
    • admin@localhost/administrator
  • If you see the following error message : "Unable to find 'pgsql' php extension/function. Fix the problem and re-run the install script." Edit your php.ini file‏, and uncomment the following line and then restart Apache :
 extension=php_pgsql.dll
    • Further discussion of this issue is available here, in case the problem has deeper causes.

The first time you bring up Midas, it will take you to an install screen. Any errors or warnings will be presented to you, along with suggestions for fixes and even the ability to fix certain problems via the web page. Many of these warnings will relate to external dependencies.

  • Install ImageMagick from here. For ImageMagick issues, there is a problem on Windows in that the ImageMagick convert.exe file is not used, rather a Windows system convert.exe occurs earlier in the path and is used instead. Several possible solutions are available here.
  • To enable the curl php extension, edit your php.ini file, uncomment the following line, and restart Apache:
 extension=php_curl.dl
  • To enable the openssl php extension, edit your php.ini file, uncomment the following line, and restart Apache:
 extension=php_openssl.dll
  • Install a Windows binary of Antiword here and add its install location to your system path, then restart Apache.
  • Install mplayer from here, add its install location to your system path, then restart Apache.

Mac

The following instructions are for installing Midas on Mac OSX Snow Leopard with MacPorts.

Server Installation

  • Get MacPorts
  • Update your port database
sudo port selfupdate
  • Install Apache
sudo port install apache2
sudo port load apache2
  • Install ImageMagick
sudo port install ImageMagick
  • Install PHP
sudo port install php5 +apache2
sudo port install php5-gd
sudo port install php5-postgresql +postgresql84
sudo port install php5-curl
sudo port install p5-mail-sendmail
sudo port install php5-openssl
  • Install Postgres 8.4
sudo port install postgresql84
sudo port install postgresql84-server
sudo port load postgresql84-server

Configure PHP

  • Load the PHP Apache module
cd /opt/local/apache2/modules
sudo /opt/local/apache2/bin/apxs -a -e -n "php5" ./libphp5.so
sudo cp /opt/local/etc/php5/php.ini-development /opt/local/etc/php.ini
  • Edit /opt/local/etc/php.ini and set or add the following values
post_max_size = 2047M
upload_max_filesize = 2047M
memory_limit = 64M
extension=php_pgsql.dll

Configure Apache

<Directory /opt/local/apache2/htdocs/Midas>
   Options Indexes FollowSymLinks MultiViews
   AllowOverride All
   Order allow,deny
   allow from all
</Directory>
AddHandler php-script php
AddType text/html php
DirectoryIndex index.html index.php
  • Add a helpful alias to ~/.profile
alias apache2ctl='sudo /opt/local/apache2/bin/apachectl'
  • Use the alias to start Apache (can also start/restart)
source ~/.profile
apache2ctl start

Configure Postgres

  • Create a database (these instructions appear when you install postgres84 from MacPorts)
mkdir -p /opt/local/var/db/postgresql84/defaultdb
sudo chown postgres:postgres /opt/local/var/db/postgresql84/defaultdb
sudo su postgres -c '/opt/local/lib/postgresql84/bin/initdb -D /opt/local/var/db/postgresql84/defaultdb'
sudo sysctl -w kern.sysv.shmall=65536
sudo sysctl -w kern.sysv.shmmax=16777216
    • then edit /etc/sysctl.conf (the file may not exist yet), and add the following lines
kern.sysv.shmall=65536
kern.sysv.shmmax=16777216
  • If you ever need to edit other database options, execute a command like this
sudo su postgres -c 'vim /opt/local/var/db/postgresql84/defaultdb/pg_hba.conf'
export PATH=$PATH:/opt/local/lib/postgresql84/bin
PGPATH=/opt/local/var/db/postgresql84/defaultdb
alias pgstart="sudo su postgres -c 'pg_ctl -D $PGPATH -l $PGPATH/logfile start'"
alias pgstop="sudo su postgres -c 'pg_ctl -D $PGPATH stop -m fast'"
alias pgstatus="sudo su postgres -c 'pg_ctl status -D PGPATH'"
  • Use like this to start postgres
source ~/.profile
pgstart
  • Install PHP JSON package (Note: I think you need to make file json.ini containing "extension=json.so" and add it somewhere, not sure where. Perhaps /opt/local/etc or /opt/local/etc/php5?)
sudo pecl install json

MIDAS Installation

  • Clone MIDAS somewhere
 git clone git://public.kitware.com/MIDAS/Midas.git
  • Make it accessible to the Apache by executing the following
sudo chgrp -R _www path_to_midas_checkout
sudo chmod -R g+rw path_to_midas_checkout
sudo ln -s path_to_midas_checkout /opt/local/apache2/htdocs/Midas
  • Create the user and table midas: (If you make a mistake, use dropdb and dropuser to undo your changes.)
 sudo -u postgres createuser -U postgres -W -d -S -P midas
 sudo -u postgres createdb -U midas -W -E UNICODE midas
  • Enter the password for the new role 'midas'
  • Shall the new role be allowed to create more new roles? No
  • Enter password: type the password set in the first step
  • Edit Midas/midas/config/config.php
 // Password for PostGres database access
 $MIDAS_PG_DB_PASS = 'password you set for the user midas';
  • Create Midas/midas/config/config.local.php, copy the code from Midas/midas/config/config.php (only from line 1 to /** WARNING: DO NOT EDIT BEYOND THIS POINT **/) and paste it into config.local.php.
    • Warning: this file should begin with '<?php' and end with '?>'.
    • Edit config.local.php
$MIDAS_BASE_DIRECTORY='path_to_midas_checkout';
    • If you want to enable plugins, add lines like this to the $MIDAS_PLUGINS list
'nonproliferation' => 1,
  • Visit http://localhost/Midas, make sure there is no red on the install page, then click "Install MIDAS"
  • The default administrator login pass:
    • admin@localhost/administrator


MIDAS Server Installation

Installing Midas from Source

  • When performing a git clone, there are several Midas Git Repositories. The get@ form will be a contributer repository, with write access, and will require acceptance as a Midas contributer and will be based off passing in a public key. The other repositories are read-only.
  • You will need cmake version 2.8.2 or later for this to work (Superbuild's interaction between git and cmake)
# In Unix-like environments
# Assumptions:
#     source dir is ~/src
#     bin dir is ~/bin
#     Apache web root is /var/www
#     Apache user is www-data
cd ~/src
# checkout MIDAS source code
git clone git://public.kitware.com/MIDAS/Midas.git
cd ~/bin
mkdir Midas-Build
cd Midas-Build
ccmake ~/src/Midas
# edit config values to suit your needs within cmake
#     Midas_BASE_DIRECTORY should be a permanent location with available storage
#     /tmp is a bad choice as files will be garbage collected here
#     Midas_USE_SUPERBUILD should be checked
# configure
# generate
# exit ccmake
make
# change the ownership of the built Midas to Apache user
sudo chown -R www-data:www-data Midas
cd /var/www/
# create a symlink from the webroot to the build directory
# assumes you set Midas_SERVER_URL as http://localhost/Midas/midas when building the Midas source
sudo ln -s ~/bin/Midas-Build/Midas Midas


# In Windows environments with XAMPP
# Assumptions:
#     source dir is C:\src
#     bin dir is C:\bin
#     Apache web root is C:\xampp\htdocs
#     command prompt is run with Admin privileges
cd C:\src
# checkout MIDAS source code
git clone git://public.kitware.com/MIDAS/Midas.git
cd C:\bin
mkdir Midas-Build
cd Midas-Build
cmake-gui
# edit config values to suit your needs within cmake
#     set the correct compiler for your system
#     source dir: C:\src\Midas
#     build dir:  C:\bin\Midas-build\
#     Midas_BASE_DIRECTORY should be a permanent location with available storage
#     Midas_USE_SUPERBUILD should be checked
# configure
# generate
# exit cmake
# 
# open Midas solution project file in appropriate IDE, then build the solution
#
# make sure that Midas/midas/tmp and the Midas_BASE_DIRECTORY are writable by the apache2 user
#     Right click on the folder -> Properties
#     In the tab Security, edit the permissions if you need
#
# create a symlink from the webroot to the build directory
# assumes you set Midas_SERVER_URL as http://localhost/Midas/midas when building the Midas source
mklink /D C:\xampp\htdocs\Midas C:\bin\Midas-build\Midas

Reinstalling MIDAS

  • Stop Apache
apache2ctl stop
  • Drop midas database
sudo -u postgres psql
> drop database midas;
> \q
  • Recreate midas database
sudo -u postgres createdb -U midas -W -E UNICODE midas
  • Start Apache
apache2ctl start

Maintaining MIDAS

Installing Eaccelerator

Eaccelerator does PHP caching of non-optimized PHP code. It's not useful when installing MIDAS to a customer since Zend Guard does optimize the code but might be worth to try:

 http://2bits.com/articles/installing-eaccelerator-0-9-5-1-on-ubuntu-feisty-7-04.html

Import Dump file

psql -d midas -U midas < dump.sql

Change database owner

 \d pg_user

note the usesysid of the user you want to change to

 \d pg_database

update pg_database SET datdba='userid' WHERE datname='midas';

CakePHP with Session using ProxyPass

The security level in core.php should be set to 'low' in order to enable session.

Better security

A cookie can be set manually by the user and CakePHP will not regenerate the session. However, in the config/core.php set the:

 Configure::write('Security.level', 'high');

Also in the /libs/cake/cake_session.php, if you want to generate a new id even if the user passes a session id the first time (this is mainly for the security checker). Add the following lines to the _checkValid() function in the last else()

 if(Configure::read('Security.level') === 'high') 
   {
   if (session_id() != || isset($_COOKIE[session_name()])) 
     {
     $this->renew();
     }
   }

Installation issues

  • Starting MIDAS 2.2, the tree view uses procedural language and you need sufficient access to create the language. You can run this command from the command line if all else fails.
 createlang -U postgres plpgsql midas
  • Note that for some unknown reason this causes a warning in the Cache::configure of CakePHP

External Midas Dependencies

  • Apache
  • PostGreSQL
  • PHP
  • ImageMagick: used to create thumbnails
  • Curl: used for testing, may be used more widely in the future
  • Openssl: used by LDAP
  • Antiword & Pdftotext: used to extract text from pdfs and word docs that have been stored in Midas, so that this text can be a part of

search results

  • Mplayer & ffmpeg (comes along with the Mplayer install): used to extract info from videos, so that if you take a video as a bitstream

and group it into a resource, that resource metadata will be populated from info extracted from the video file

  • Sendmail: used to send mail from a Midas server, for instance when creating user accounts
Personal tools