Skip to content
This repository was archived by the owner on Mar 24, 2020. It is now read-only.
Matthew Critchlow edited this page Oct 20, 2015 · 11 revisions

Windows

Let's not go there.

Apple/OSX

Install Command Line Tools

For Mavericks (10.9): run sudo xcodebuild -license and follow the instructions to accept the XCode agreement. Then run xcode-select --install in your terminal and then click "Install".

XCode Command Line Tools Homebrew Compatibility Chart

Setup Ruby/Rails (OSX)

  1. Install homebrew

    $ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  2. Run brew doctor and fix any issues that are reported before proceeding

    $ brew doctor
  3. Install automake

    $ brew install automake
  4. Install rbenv

    $ brew install rbenv ruby-build rbenv-gem-rehash

    or:

    $ git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
    $ git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
    $ git clone https://github.com/sstephenson/rbenv-gem-rehash.git ~/.rbenv/plugins/rbenv-gem-rehash
  5. Update your .bashrc to use rbenv by default:

    export PATH=$HOME/.rbenv/bin:$PATH
    eval "$(rbenv init -)"
    
  6. Install Ruby 2.2.3 and set as default

    $ rbenv install 2.2.3
    $ rbenv global 2.2.3
    $ gem install bundler
  7. Confirm Ruby 2.2.3 is the default ruby

    $ ruby --version

    _If the version shown is not 2.2.3+, set default directly.

  8. Install Node.js (for updating Javascript libraries with bower)

    $ brew install node

Prerequisites

Confirm all commands below return correct versions. Note this can easily get out of date. To be sure, look at the .ruby-version file in the repository.

  • Ruby 2.2.3+ $ ruby -v
  • git $ git --version
  • node $ node --version

Check out DAMSPAS from GIT

  1. Clone Project: git clone https://github.com/ucsdlib/damspas.git
  2. Open Project: cd damspas
  3. Check out develop branch: git checkout develop
  4. Copy DB Sample: cp config/database.yml.sample config/database.yml
  5. Copy Fedora Sample: cp config/fedora.yml.sample config/fedora.yml
  6. Copy Solr Sample: cp config/solr.yml.sample config/solr.yml
  7. Copy Devise initializer: cp config/initializers/devise.rb.sample config/initializers/devise.rb
  8. Copy Secret Token Sample: cp config/initializers/secret_token.rb.sample config/initializers/secret_token.rb
  9. Edit config/initializers/secret_token.rb and replace the long hex string with a new random string (you can generate a new random key with rake secret or openssl rand 64 -hex).
  10. Edit the wowza_directory property in config/environments/test.rb to point to a dummy streaming.key file on your local machine
  11. Install gems: bundle install For RHEL, need to install packages: automake, gcc-c++, libxml2-devel, libxslt-devel, sqlite-devel.
  12. Update DB: bundle exec rake db:migrate

Running DAMS PAS

WEBrick

The simplest Rails server is the built-in WEBrick. Just run:

$ rails s

And DAMS PAS will be available at http://localhost:3000/

WEBrick has some limitations, in particular it's single-threaded, slow and can't handle streaming large files.

Unicorn

For a faster, multi-threaded webserver that can handle large files, Unicorn is almost as easy:

$ unicorn -p 8081

This will run DAMS PAS at http://localhost:8081/ -- you can specify any port you like, but the default port (8080) is also the default port for Jetty and Tomcat, so you probably need to specify something.

Passenger

Production deployment is typically done using Passenger (mod_rails) paired with Apache or Nginx. This is more complicated to setup, but has the advantage of using the same stack in all environments and being able to use the same configuration.

  1. Install or enable Apache. On MacOSX 10.8 (Mountain Lion), this has been removed from the System Preferences Sharing panel, but can be done using the command line:

    $ sudo defaults write /System/Library/LaunchDaemons/org.apache.httpd Disabled -bool false
  2. Install Passenger gem:

    $ gem install passenger
  3. Install cURL development headers (needed by RHEL):

    $ sudo yum install curl-devel
  4. Install Apache module:

    $ passenger-install-apache2-module
  5. Configure Apache, taking the configuration directives from the module install output, and placing them in a file that will be loaded by Apache. In MacOSX, the file should be in /etc/apache2/other/, in RHEL, it should be in /etc/httpd/conf.d/. This should be named something passenger.conf and look like:

    LoadModule passenger_module /usr/local/var/rbenv/versions/2.0.0-p481/lib/ruby/gems/2.0.0/gems/passenger-4.0.44/buildout/apache2/mod_passenger.so
    PassengerRoot /usr/local/var/rbenv/versions/2.0.0-p481/lib/ruby/gems/2.0.0/gems/passenger-4.0.44
    PassengerDefaultRuby /usr/local/var/rbenv/versions/2.0.0-p481/bin/ruby
    PassengerBufferResponse off # disable buffering to allow streaming large files
    <Directory /var/www/html/damspas>
      Allow from all
      Options -MultiViews
      RackBaseURI /damspas
      RailsEnv "development"
    </Directory>
    
  6. Omniauth ignores the RackBaseURI, so you may want to rewrite the authentication callback URLs without the RackBaseURI:

    RewriteEngine On
    RewriteLog /var/log/apache2/rewrite.log
    RewriteLogLevel 9
    RewriteCond %{REQUEST_URI} /users
    RewriteRule ^/users(.*) /damspas/users/$1 [P,L]
    
  7. Create a symlink from the web space to the public directory of DAMS PAS:

    $ cd /var/www/html
    $ ln -s /path/to/damspas/public damspas

    On MacOSX, the web root will be in /Library/WebServer/Documents by default.

  8. Restart Apache:

    $ sudo apachectl restart

    DAMS PAS will be available at http://localhost/damspas/