Skip to content

Latest commit

 

History

History
184 lines (114 loc) · 5.99 KB

2- INSTALL.rdoc

File metadata and controls

184 lines (114 loc) · 5.99 KB

Installation instructions

This document describes how to bootstrap into the webapplication. The documentation is updated for Ubuntu 18.14 LTS.

Requirements

The following other libraries and programs are needed

  • ruby: > 2.3

  • Apache 2.2

  • MySQL > 5.0

  • Git

  • Passenger for Apache 2

  • rails

  • ruby-bundler

  • libmysqlclient-dev

  • imagemagick

  • libmagickwand-dev

Ruby and Rails

Muscat 4 now requires ruby 2.3 by default. Rails is installed with the correct version with bundle. Ubuntu comes with ruby 2.5 by default so no actions are necessary. On older Debian systems the easyest way to get ruby 2.3 is via rbenv adding for all users.

On older Ubuntu systems add the following repositories

deb http://ppa.launchpad.net/brightbox/ruby-ng/ubuntu trusty main
deb https://oss-binaries.phusionpassenger.com/apt/passenger trusty main

(On some systems it is necessary to uncomment therubyracer from the gemfile) On Ubuntu 18.04 only passenger is needed:

deb https://oss-binaries.phusionpassenger.com/apt/passenger bionic main

(Add /etc/apt/sources.list or create a relevant file in /etc/apt/sources.list.d) Also make sure that universe repositories are enabled!

On 18.40, also enable GPG verification of Passenger:

sudo apt-get install -y dirmngr gnupg
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 561F9B9CAC40B2F7
sudo apt-get install -y apt-transport-https ca-certificates

Then install all the dependencies and setup passenger:

sudo apt-get update
sudo apt-get install mysql-server apache2 git ruby ruby-dev gcc zlib1g-dev libxml2-dev imagemagick libmagickcore-6.q16-dev libmagickwand-6.q16-dev libmysqlclient-dev openjdk-8-jdk-headless passenger libapache2-mod-passenger
sudo a2enmod passenger

Passenger also wants to compile a binary module, this is optional but will enable it

sudo mkdir /var/www/.passenger
sudo chown -R www-data:www-data /var/www/.passenger

Bootstrap the application

Get the sources if necessary (github.com/rism-ch/muscat and github.com/rism-ch/muscat-guidelines):

git clone https://github.com/rism-ch/muscat.git --recursive

sudo gem install bundler -v '< 2.0' ## force 1.7 until we get compatibile with 2.0
sudo bundle install #--deployment # deployment is only for the production system

Install base configuration:

cd muscat/config
cp sample_database.yml database.yml
cp sample_application.rb application.rb

Install the base css:

cd muscat/config
cp muscat-custom-sample.scss ../vendor/assets/stylesheets/muscat-custom.scss

Make sure the directory is owned by the right user (www-data on ubuntu)

sudo chown -R www-data:www-data muscat/

Set up databases access:

sudo mysql # Or log in with a user that has user creation privileges

Create the user, substitute with an appropriate user and password!

CREATE DATABASE muscat_development CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE USER 'rism'@'localhost';
SET PASSWORD FOR 'rism'@'localhost' = PASSWORD('password');
GRANT ALL ON muscat_development.* TO 'rism'@'localhost';

Remember username and pass should be the same as in database.yml Migrate the database NOTE in a production environment all the tasks must declare RAILS_ENV=production to run. For local development this is not necessary

bundle exec rake db:migrate # development
sudo RAILS_ENV=production bundle exec rake db:migrate ## on a production system

Add basic dataset:

bundle exec rake db:seed

Default (development) startup:

bundle exec rake sunspot:solr:start
rails s -e development

Try to open $IP_ADDRESS:3000/

For startup in production mode see “Starting Daemons in Production Mode”

For refreshing an installation in production mode (with sudo, as root or sudo -u www-data depending on the permissions on the installation dir):

bundle exec rake RAILS_ENV=production assets:clean
bundle exec rake RAILS_ENV=production assets:precompile

Logging In

A default administrative user has been created as part of the installation process. To log in, go to ‘ip:3000/admin` and log in with the following credentials:

username: [email protected]
password: password

It is advised that you delete this account after creating a new administrative user in the admin interface.

Index rebuilding:

rake sunspot:reindex

it in production mode run

RAILS_ENV=production rake sunspot:reindex

Specify only a model:

rake sunspot:reindex[,Person]

Do reindex in 1 record batches, useful if reindex crashes to see in which one (very slow to start)

rake sunspot:reindex[1]

To install on Mac OS X Lion

With MySQL 64 bit binaries, add:

export DYLD_LIBRARY_PATH="/usr/local/mysql/lib:$DYLD_LIBRARY_PATH"

Basic Apache configuration

Example Apache configuration:

# create /usr/local/etc/apache/Includes/default.conf
# and add default site:
<VirtualHost *:80>
        # ServerName www..org
        DocumentRoot /var/rails/rism-ch/public
        <Directory "/var/rails/rism-ch/public">
                Options All -Indexes +ExecCGI -Includes +MultiViewsny
                Require all granted
        </Directory>
        RailsEnv production
</VirtualHost>

Double check permissions in the muscat installation. Also make sure DocumentRoot and Directory point to public/ in the muscat installation location.

Start Apache, Solr and the related services in production mode (see below).

Starting Daemons in Production Mode

Muscat has three running daemons that should be started:

 sudo RAILS_ENV=production bin/delayed_job start
 sudo RAILS_ENV=production bundle exec crono start
 # Make sure solr is not running as root!
 sudo -u www-data bundle exec rake RAILS_ENV=production sunspot:solr:start

Depending on the env, remove sudo if necessary. RAILS_ENV is needed only on production, and has to come after sudo.

Also it is goot to block access to SOLR:

sudo iptables -A INPUT -p tcp -s localhost --dport 8983 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 8983 -j DROP

Add clean up in crontab for blacklight

0 2 * * * cd $PATH_TO && $PATH_TO/bin/rake blacklight:delete_old_searches[7] RAILS_ENV=production