Metadot Ubuntu 9.04 Install Guide

Prerequisites:

1. Install Apache:

Apt-get install apache2

2. Install Sendmail (for sending site, user, and registration notices):

Apt-get install sendmail

3. Install MySQL:

Apt-get install mysql-server

The install will prompt you to set a password for mysql root user. Enter it and confirm.

4. Install Ruby (Ruby 1.8 is the only version that I know for sure works with metadot):

Apt-get install ruby1.8

5. Install Ruby Gems (you need the version that corresponds with the version of Ruby you installed):

Apt-get install rubygems1.8

6. Install Rake:

Installing rake through ruby gems is supposed to be all you need, but I had to do both commands to make it work properly. Version 0.7.3 is the only currently supported version.

gem install --remote rake -v 0.7.3

Apt-get install rake

7. Install Ferret & MySQL gems:

You will need to pull in some dependencies for these first. Double check your mysql paths below are correct for your installation.

apt-get install ruby1.8-dev

apt-get install libmysql++-dev

gem install ferret -v 0.11.5

gem install mysql  --with-mysql-config=/usr/bin/mysql_config --with-mysql-lib=/usr/lib/mysql

8. Make sure ‘make’ is installed:

Apt-get install make

Install Metadot 7:

1. Unpack the package file in the folder where your site will reside (e.g. /path/to/yoursite):

Tar -xzvf metadot-package-7.4.6.tar.gz –C /path/to/yoursite

2. Go to your site folder (e.g. /path/to/yoursite):

Cd /path/to/yoursite

3. Run “install” command. The format is:./install [--no-tests] db_name_prefix [db_root_password]

Sections in brackets are optional.

Parameters:

* –no-tests – skip the test during the installation (optional)

* db_name_prefix – database prefix name

* db_root_password – database password for the root user that you entered while installing MySQL earlier (optional)

Example:

./install my_metadot_db db_root_password

Note: If the databases exists, they will be dropped first and then created again.

4. Go to the created folder “metadot-rails” and create the search index for development and production databases:

cd /path/to/yoursite/metadot-rails

rake create_search_index

rake create_search_index RAILS_ENV=production

cd search

chown -R www-data:www-data production

# The above rake command sets perms as root:root which breaks search function. So you have to chown the permissions on the search index back to www-data:www-data

5. Run the site in development mode to test the install script worked properly:

cd /path/to/yoursite/metadot-rails

ruby script/server

The site should be found at http://your-machine-ip:3000

Initial login:

email: admin@yoursite.com

password: admin123

After you login for the first time be sure to go change your email and password for security reasons.

Install FastCGI (requires either fcgid OR fastcgi, but not BOTH. We used fcgid):

apt-get install libapache2-mod-fcgid

7. Now you need to configure the fcgid module:

Here is an example of our fcgid configuration.

Cat /etc/apache2/mod-enabled/fcgid.conf

<IfModule mod_fcgid.c>

AddHandler    fcgid-script .fcgi

IPCConnectTimeout 20

# Metadot added this:

# IdleTimeout n (300 seconds)

# An idle fastcgi application will be terminated after IdleTimeout seconds.

IdleTimeout 900

# IdleScanInterval n (120 seconds)

# The scan interval for idle fastcgi applications.

IdleScanInterval 120

# BusyTimeout n (300 seconds)

# A fastcgi application will be terminated if handing a single request

# longer than busy timeout.

BusyTimeout 300

# BusyScanInterval n (120 seconds)

# The scan interval for busy timeout fastcgi applications.

BusyScanInterval 120

# ErrorScanInterval n (3 seconds)

# The scan interval for exit pending fastcgi applications. fastcgi

# applications will be terminated within this scanning.

ErrorScanInterval 9

# ZombieScanInterval n (3 seconds)

# The scan interval for zombie process.

ZombieScanInterval 9

# ProcessLifeTime n (3600 seconds)

# A fastcgi application will be terminated if lifetime expired,

# even no error is detected.

ProcessLifeTime 3600

# MaxProcessCount n (1000)

# The max count of total fastcgi process count.

MaxProcessCount 15

# DefaultMaxClassProcessCount n (100)

# The maximum number of fastcgi application instances allowed to run for

# particular one fastcgi application.

DefaultMaxClassProcessCount 8

# DefaultMinClassProcessCount n (3)

# The minimum number of fastcgi application instances for any one fastcgi

# application.

# Idle fastcgi will not be killed if their count is less than n

# Set this to 0, and tweak IdleTimeout

DefaultMinClassProcessCount 6

</IfModule>

8. Configure the virtual host for apache2:
Here is an example of the our apache virtualhost configuration.

cat /etc/apache2/sites-enabled/metadot.conf

<VirtualHost *:80>

ServerName yourcompany.com

ServerAlias www.yourcompany.com

DocumentRoot /path/to/your/site/metadot/metadot-rails/public

<Directory /path/to/your/site/metadot/metadot-rails/public>

Options -Indexes FollowSymLinks ExecCGI

AllowOverride All

Order allow,deny

Allow from all

</Directory>

</VirtualHost>

9. Create the .htaccess file for the metadot-rails/public directory:

cd /path/to/yoursite/metadot-rails/public

Here is an example of our .htaccess file.

Cat /path/to/yoursite/metadot-rails/public/.htaccess

# Look in /etc/apache2/mods-enabled/fcgid.conf to see how fcgi is

# configured

###

RewriteEngine On

<IfModule mod_fcgid.c>

AddHandler fcgid-script .fcgi

</IfModule>

Options +Indexes +MultiViews +FollowSymLinks +ExecCGI

RewriteRule ^$ index.html [QSA]

RewriteRule ^([^.]+)$ $1.html [QSA]

###

### For out of service situation, enable the following two lines.

###

#RewriteCond %{REQUEST_FILENAME} !-f

#RewriteRule ^(.*)$ out_of_service.html [QSA,L]

# Redirect all requests not available on the filesystem to Rails

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !/__metadot__/public(.*)

RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]

ErrorDocument 500 “<h2>Application error</h2><p>Rails application failed to start properly.</p>”

10. Create index again and enable apache modules:

cd /path/to/yoursite/metadot-rails

rake create_search_index RAILS_ENV=production

Enable the apache modules:

a2enmod fcgid

a2enmod rewrite

Enable the site:

a2ensite sitename

Now restart apache for the changes to take effect:

/etc/init.d/apache2 restart

Additional Configurations:

1. Setup cron job to recreate/update the site search index:

Edit the /etc/crontab and add the following (keep in mind that the ‘’ is to show that the same line continues below. Be sure to remove those):

# Rake to create site indexes

0,15,30,45 * * * * cd /path/to/your/site/metadot-rails/ && /usr/bin/rake periodic_processing RAILS_ENV=production

#

# Metadot: Remove session files older than 10 hours.

#

14 3 * * * root find /tmp -type f -name ‘ruby_sess.*’ -mmin +600 -type f -print0 | xargs -0

–no-run-if-empty rm

2. Modify the environment and mail template files to insert your proper domain and site info:

In /path/to/yoursite/metadot-rails/app/models/user.rb:

Change “true” to “false” if you don’t have the www at the beginning of the site’s address (http://servername.tld instead of http://www.servername.tld)

self.account.base_url(:include_www => false) + “/#{MANAGE_PATH_BEGIN}/login/reset_password/” + self.security_token

In the config/environment.rb file:

Change the following:

HOST_BASE = “yourdomain”

EMAIL_SUBJECT_TAG = “[Your Custom Email Subject]“

EMAIL_FOOTER = “<<< Your Custom Footer >>>”

WEB_PAGE_FOOTER = %{<a href=”<a site link here”>Your Alt Txt Here</a>}

SYSTEM_NOTIFIER_SENDER = %{“Sender Display Name” <Sender’s Email Address>}

SYSTEM_NOTIFIER_RECIPIENTS = %w{Sender’s Email Address}

You may also need to edit the DB itself and change “site_name” in the accounts table to your actual server/site name <servername>

3. Reboot for good measure