Temp
Contents
- 1 Introduction
- 2 Installation
- 2.1 Step 1 - Install Ubuntu server
- 2.2 Step 2 - Install web app framework on the server
- 2.3 Step 3 - Get the DMP code
- 2.4 Step 4 - Configure database connection
- 2.5 Step 5 - Prepare the databases
- 2.6 Step 6 - Configure super-admin access to the application
- 2.7 Step 7 - Install the dependencies
- 2.8 Step 8 - Deploy the web app using "passenger"
- 2.9 Step 9 - Prepare the Apache web server
- 2.10 Step 10 - Start the web app
- 3 References
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.
Installation
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.
Step 2 - Install web app framework on the server
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;
# MySQL. Versions 4.1 and 5.0 are recommended. # # Install the MYSQL driver # gem install mysql2 # # Ensure the MySQL gem is defined in your Gemfile # gem 'mysql2' # # And be sure to use new-style password hashing: # http://dev.mysql.com/doc/refman/5.0/en/old-client.html 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.
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.
- For "production"
Type the following;
RAILS_ENV="production" rake db:create RAILS_ENV="production" rake db:migrate RAILS_ENV="production" rake db:seed
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
Step 6 - Configure super-admin access to the application
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.
- Sample File
production: admin_name: Prod User admin_email: XXXXXXX admin_password: XXXXXXX secret_key_base: XXXXXX
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' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 4.2', '>= 4.2.6' # Use mysql as the database for Active Record gem 'mysql2', '>= 0.3.18', '< 0.5' # Use Puma as the app server gem 'puma', '~> 3.0' # Use SCSS for stylesheets #gem 'sass' gem 'sass-rails', '~> 5.0' gem 'less-rails' gem 'twitter-bootstrap-rails' # Use Uglifier as compressor for JavaScript assets gem 'uglifier', '>= 1.3.0' # Use CoffeeScript for .coffee assets and views gem 'coffee-rails', '~> 4.2' # See https://github.com/rails/execjs#readme for more supported runtimes gem 'therubyracer', platforms: :ruby # Use jquery as the JavaScript library gem 'jquery-rails' # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks #gem 'turbolinks', '~> 5' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.5' # Use Redis adapter to run Action Cable in production # gem 'redis', '~> 3.0' # Use ActiveModel has_secure_password # gem 'bcrypt', '~> 3.1.7' # Use Capistrano for deployment # gem 'capistrano-rails', group: :development #group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console # gem "better_errors" # gem "binding_of_caller" # gem 'byebug', platform: :mri #end #group :development do # # Access an IRB console on exception pages or by using <%= console %> anywhere in the code. # gem 'web-console' # gem 'listen', '~> 3.0.5' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring # gem 'spring' # gem 'spring-watcher-listen', '~> 2.0.0' #end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem #gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] # Custom gems for DMPonline 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'
Type the following;
cd ~/DMPonline_v4 gem install bundler bundle install --deployment --without development test
Step 8 - Deploy the web app using "passenger"
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
<IfModule mod_passenger.c>
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
</IfModule>
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 <Directory> parameters as shown in the example below.
Example Apache web config
<VirtualHost *:80>
# 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
<IfModule mod_passenger.c>
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
</IfModule>
<Directory /home/dmponline/DMPonline_v4/public>
Allow from all
Options -MultiViews
# Uncomment this if you're on Apache >= 2.4:
Require all granted
</Directory>
# 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
</VirtualHost>
# 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
References
Source Code
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)
