This document describes how to bootstrap into the webapplication.
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
Muscat 4 now requires ruby 2.3 by default. Rails is installed with the correct version with bundle. On some systems it is necessary to uncomment therubyracer from the gemfile
On older Debian systems the easyest way to get ruby 2.3 is via rbenv adding for all users.
On Ubuntu systems pre-packaged binaries exist: add
deb http://ppa.launchpad.net/brightbox/ruby-ng/ubuntu trusty main deb https://oss-binaries.phusionpassenger.com/apt/passenger trusty main
To /etc/apt/sources.list or create a relevant file in /etc/apt/sources.list.d
Then (all as root or with sudo)
apt-get update apt-get install ruby2.3 ruby2.3-dev apt-get install passenger libapache2-mod-passenger a2enmod passenger update-alternatives --set ruby /usr/bin/ruby2.3
Passenger also wants to compile a binary module, this is optional but will enable it
mkdir /var/www/.passenger sudo chown -R www-data:www-data /var/www/.passenger
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 gem install bundler bundle install --deployment # deployment is 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
Set up databases access:
mysql > CREATE DATABASE muscat_development CHARACTER SET utf8 COLLATE utf8_general_ci; > CREATE USER 'username'@'localhost'; > SET PASSWORD FOR 'username'@'localhost' = PASSWORD('pass'); > GRANT ALL ON muscat_development.* TO 'username'@'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 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 :
http://ip:3000/
For startup in production mode (with sudo or as root):
bundle exec rake RAILS_ENV=production assets:precompile bundle exec rake RAILS_ENV=production sunspot:solr:start RAILS_ENV=production bundle exec crono start # Muscat periodic jobs RAILS_ENV=production bin/delayed_job -n 4 restart # Background jobs, tune the n to your system
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
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.
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]
With MySQL 64 bit binaries, add:
export DYLD_LIBRARY_PATH="/usr/local/mysql/lib:$DYLD_LIBRARY_PATH"
Example Apache configuration:
# create /usr/local/etc/apache22/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 +MultiViews AllowOverride All Order allow,deny Allow from all </Directory> RailsEnv development </VirtualHost>
Double check permissions:
# Create /var/rails and populate with software mkdir /var/rails <command to checkout as needed TBD> chown -R www /var/rails
Start Apache and Solr.
If all this works, you can access the rism application:
http://IP
0 2 * * * cd $PATH_TO && $PATH_TO/bin/rake blacklight:delete_old_searches[7] RAILS_ENV=production == Starting Daemons 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 sudo 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.