Temp

Introduction
This wiki page details the installation and use of the DCC RDMP software (RDMP = Research Data Management Plan) on an Ubuntu 14.04 LTS server with the "RubyonRails" web development framework installed.

Step 1 - Install Ubuntu server
Install an Ubuntu 14.04 LTS server as per: http://ubuntu.sun.ac.za/wiki/index.php/Enterprise_Server_Management Use "tasksel" and install the "LAMP server" and the "OpenSSH server". See screenshot below.


 * When asked for a password for the MySQL server, type in a VERY SECRET password and do not forget it!
 * When asked for the user account details, use "dmponline" as the installed user name.!



See: http://tecadmin.net/install-lamp-quickly-using-tasksel-on-ubuntu-and-linuxmint/ for reference.

Install the prerequisites
Login to the server and then type the following; sudo apt-get install libmysqlclient-dev curl gnupg2

Install RubyonRails
Install Ruby as a normal user as follows; gpg2 --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 \curl -L https://get.rvm.io | bash -s stable --ruby echo "source ~/.rvm/scripts/rvm" >> ~/.bashrc Logout and login again, then check the installed Ruby version; ruby -v ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]

Install the "rails" framework; gem install rails --version=4.2.6 Check version; rails -v Rails 4.2.6

Install Nodejs
Type the following; curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash - sudo apt-get install -y nodejs Check version; nodejs -v v4.4.6

Step 3 - Get the DMP code
Type the following; git clone https://github.com/CDLUC3/dmptool.git

Step 4 - Configure database connection
Configure database access by typing the following; cd ~/dmptool nano config/database.yml Copy and paste the following; production: adapter: mysql2 encoding: utf8 reconnect: false database: dmponline_production pool: 5 username: root password: %PASSWORD% socket: /var/run/mysqld/mysqld.sock ''' Replace %PASSWORD% with the "root" password for your MySQL database. '''
 * 1) MySQL.  Versions 4.1 and 5.0 are recommended.
 * 2) Install the MYSQL driver
 * 3)   gem install mysql2
 * 4) Ensure the MySQL gem is defined in your Gemfile
 * 5)   gem 'mysql2'
 * 6) And be sure to use new-style password hashing:
 * 7)   http://dev.mysql.com/doc/refman/5.0/en/old-client.html
 * 1) And be sure to use new-style password hashing:
 * 2)   http://dev.mysql.com/doc/refman/5.0/en/old-client.html
 * 1)   http://dev.mysql.com/doc/refman/5.0/en/old-client.html

Step 5 - Prepare the databases
Type the following; cd ~/dmptool RAILS_ENV="production" rails dbconsole This will connect you to the database. If successful then continue, otherwise check the database config above.

Type the following; RAILS_ENV="production" rake db:create RAILS_ENV="production" rake db:migrate RAILS_ENV="production" rake db:seed
 * For "production"

If there is an error and you need to drop the database to try again, then type the following; RAILS_ENV="production" rake db:reset

Install Rails secrets
Rails also needs a unique secret key with which to encrypt its sessions. Starting from Rails 4, this secret key is stored in config/secrets.yml. But first, we need to generate a secret key. Run: cd ~/dmptool RAILS_ENV=production rake secret The commands will output a secret keys. Copy their values to your clipboard. Next, open config/secrets.yml: cd ~/dmptool nano config/secrets.yml If the file already exists, look for this: secret_key_base: <%=ENV["SECRET_KEY_BASE"]%> Then replace it with the following. If the file didn't already exist, simply insert the following. secret_key_base: the value that you copied from 'rake secret'

''Now configure admin user access by copying the text in the example below and pasting it into the secrets file. Remember to include the rake secret above.'' production: admin_name: Prod User admin_email: XXXXXXX admin_password: XXXXXXX secret_key_base: XXXXXX
 * Sample File

Step 7 - Install the dependencies
Configure the local gem config as follows; cd nano .gemrc Copy and paste the following into the open file; gem: --no-document Logout and then login again and then type the following; cd ~/dmptool nano Gemfile Delete everything and then copy and paste the following; source 'https://rubygems.org'

gem 'rails', '~> 4.2', '>= 4.2.6' gem 'mysql2', '>= 0.3.18', '< 0.5' gem 'puma', '~> 3.0' gem 'sass-rails', '~> 5.0' gem 'less-rails' gem 'twitter-bootstrap-rails' gem 'uglifier', '>= 1.3.0' gem 'coffee-rails', '~> 4.2' gem 'therubyracer', platforms: :ruby
 * 1) Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
 * 1) Use mysql as the database for Active Record
 * 1) Use Puma as the app server
 * 1) Use SCSS for stylesheets
 * 2) gem 'sass'
 * 1) Use Uglifier as compressor for JavaScript assets
 * 1) Use CoffeeScript for .coffee assets and views
 * 1) See https://github.com/rails/execjs#readme for more supported runtimes

gem 'jquery-rails' gem 'jbuilder', '~> 2.5'
 * 1) Use jquery as the JavaScript library
 * 1) Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
 * 2) gem 'turbolinks', '~> 5'
 * 3) Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
 * 1) Use Redis adapter to run Action Cable in production
 * 2) gem 'redis', '~> 3.0'
 * 3) Use ActiveModel has_secure_password
 * 4) gem 'bcrypt', '~> 3.1.7'


 * 1) Use Capistrano for deployment
 * 2) gem 'capistrano-rails', group: :development

# Call 'byebug' anywhere in the code to stop execution and get a debugger console
 * 1) group :development, :test do
 * 1)  gem "better_errors"
 * 2)  gem "binding_of_caller"
 * 3)  gem 'byebug', platform: :mri
 * end

# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
 * 1) group :development do
 * 2)  # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
 * 3)  gem 'web-console'
 * 4)  gem 'listen', '~> 3.0.5'
 * 1)  gem 'spring'
 * 2)  gem 'spring-watcher-listen', '~> 2.0.0'
 * end


 * 1) Windows does not include zoneinfo files, so bundle the tzinfo-data gem
 * 2) gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

gem 'activeadmin' gem 'libv8' gem 'devise' gem 'devise_invitable' gem 'omniauth' gem 'omniauth-shibboleth' gem 'recaptcha' gem 'tinymce-rails' gem 'ledermann-rails-settings' gem 'exception_notification' gem 'amoeba' gem 'rolify' gem 'email_validator' gem 'validate_url' gem 'cancan' gem 'friendly_id' gem 'contact_us' gem 'thin' gem 'wicked_pdf' gem 'htmltoword' gem 'feedjira' gem 'caracal' gem 'caracal-rails' gem 'passenger' gem 'protected_attributes'
 * 1) Custom gems for DMPonline

Type the following; cd ~/DMPonline_v4 gem install bundler bundle install --deployment --without development test

Compile assets
Run the following command to compile assets for the Rails asset pipeline: cd ~/DMPonline_v4 bundle exec rake assets:precompile

Test the installation
Type the following; rvmsudo rails s -p 80 Follow the on screen instructions.

Install Passenger
Type the following; passenger-install-apache2-module At the end of the installation process, you will be asked to copy and paste a configuration snippet (containing LoadModule, PassengerRoot, etc.) into your Apache configuration file.

Type the following; sudo nano /etc/apache2/sites-enabled/000-default.conf Add the following; LoadModule passenger_module /home/dmponline/.rvm/gems/ruby-2.3.0/gems/passenger-5.0.29/buildout/apache2/mod_passenger.so       PassengerRoot /home/dmponline/.rvm/gems/ruby-2.3.0/gems/passenger-5.0.29 PassengerDefaultRuby /home/dmponline/.rvm/gems/ruby-2.3.0/wrappers/ruby  Restart the web server; sudo service apache2 restart

Step 9 - Prepare the Apache web server
Update the Apache web server config file as follows; sudo nano /etc/apache2/sites-enabled/000-default.conf Uncomment the "ServerName" and type the following; ServerName rdmp.bib.sun.ac.za Add the following as the "DocumentRoot"; /home/dmponline/DMPonline_v4/public Add the  parameters as shown in the example below.

Example Apache web config
 # The ServerName directive sets the request scheme, hostname and port that # the server uses to identify itself. This is used when creating # redirection URLs. In the context of virtual hosts, the ServerName # specifies what hostname must appear in the request's Host: header to       # match this virtual host. For the default virtual host (this file) this # value is not decisive as it is used as a last resort host regardless. # However, you must set it for any further virtual host explicitly. ServerName rdmp.bib.sun.ac.za

ServerAdmin webmaster@localhost DocumentRoot /home/dmponline/DMPonline_v4/public

LoadModule passenger_module /home/dmponline/.rvm/gems/ruby-2.3.0/gems/passenger-5.0.29/buildout/apache2/mod_passenger.so                       PassengerRoot /home/dmponline/.rvm/gems/ruby-2.3.0/gems/passenger-5.0.29 PassengerDefaultRuby /home/dmponline/.rvm/gems/ruby-2.3.0/wrappers/ruby 

 Allow from all Options -MultiViews # Uncomment this if you're on Apache >= 2.4: Require all granted 

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn, # error, crit, alert, emerg. # It is also possible to configure the loglevel for particular # modules, e.g.       #LogLevel info ssl:warn

ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined

# For most configuration files from conf-available/, which are # enabled or disabled at a global level, it is possible to       # include a line for only one particular virtual host. For example the # following line enables the CGI configuration for this host only # after it has been globally disabled with "a2disconf". #Include conf-available/serve-cgi-bin.conf 


 * 1) vim: syntax=apache ts=4 sw=4 sts=4 sr noet

Step 10 - Start the web app
Restart the Apache web server; sudo service apache2 restart Type the following to check the passenger installation; rvmsudo passenger-config validate-install If everything looks good then go to: http://rdmp.bib.sun.ac.za Type the following to check the memory; rvmsudo passenger-memory-stats

Source Code

 * https://github.com/DigitalCurationCentre/DMPonline_v4
 * https://github.com/CDLUC3/dmptool

Installation

 * http://railsapps.github.io/installrubyonrails-ubuntu.html
 * https://www.phusionpassenger.com/library/walkthroughs/deploy/ruby/ownserver/apache/oss/rubygems_rvm/install_passenger.html
 * https://gorails.com/setup/ubuntu/14.04
 * https://en.wikipedia.org/wiki/Capistrano_(software)

Help

 * http://guides.rubyonrails.org/getting_started.html