Skip to content

Vish Instalation Mac

aemartos edited this page Jan 9, 2018 · 24 revisions

ViSH Installation

  1. Previous requirements
    1. Generate SSH keys for GitHub
  2. Installation for development
    1. Required packages
    2. Database
      1. MySQL
      2. PostgreSQL
      3. Setting up
    3. Set up the ViSH instance
    4. Install the search engine
    5. Populate the database
    6. Start server

  • A computer with:
    • Mac OS X Lion (also works with other versions)
    • Internet connection

Install homebrew:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Install ruby2.x :

brew install rbenv ruby-build

# Add rbenv to bash so that it loads every time you open a terminal
echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
source ~/.bash_profile

# Install Ruby
rbenv install 2.2.3
rbenv global 2.2.3
ruby -v

Install Git:

# Install
brew install git

# Configure
git config --global color.ui true
git config --global user.name "YOUR NAME"
git config --global user.email "YOUR@EMAIL.com"

To access to GitHub repositories via git you need to generate public and private keys. If you have already generated SSH keys for Github, you can skip this step.
To generate the ssh keys, you can check the official github guide, or follow the next instructions.

Execute the following command:

ssh-keygen -t rsa -C "YOUR@EMAIL.com"

Accept the default name it proposes and do not introduce password (if you introduce one you will have to introduce it every time you access the repository).

In /home/{your_user}/.ssh there will be two files: id_rsa and id_rsa.pub.
Now you have to add the public key (the one in id_rsa.pub) to your GitHub account.
Copy and paste the output of the following command and paste it here

cat ~/.ssh/id_rsa.pub

To check that it has been added correctly execute the following command:

ssh git@github.com

If everything works fine, this command will print a message like "You've successfully authenticated".

 
 

First off, you have to download the source code from git.
Go to your workspace folder and execute the following command to clone the ViSH repository:

git clone https://github.com/ging/vish.git

 

##Required packages

The following packages should be installed.

brew install libxml2
brew install libxslt
brew install mysql 
brew install sqlite 
brew install postgresql
brew install nodejs

# Homebrew Formula patching old ImageMagick release 6.9.7-10 
brew install https://gist.githubusercontent.com/leesheppard/69a283ee4af484e2029809a0f5e09932/raw/88bc116b515a456a2e1bad476b6124d28ce2f6f6/imagemagick.rb

Now enter in the folder ViSH and execute the following commands: With macOS Sierra (10.12.6) comment mysql2 gem at Gemfile before bundle install.

cd vish  
gem install bundler
rbenv rehash  
bundle install

 

##Set up the ViSH instance To start the ViSH application you need to set up the ViSH instance.
First off, you must copy the file /config/application_config.yml.example to config/application_config.yml.

cp config/application_config.yml.example config/application_config.yml

This file will look something like this:

development:
  domain: "localhost:3000"
  test_domain: true
  no_reply_mail: "no-reply@vishub.org"
  main_mail: "virtual.science.hub@gmail.com"
  models:
    available: ["Excursion","Resource","Category","Event","Workshop"]
    resources: ["Document","Webapp","Scormfile","Link","Embed", "Writing"]
    home: ["Excursion"]
    catalogue: ["Excursion"]
  services: ["ARS","Catalogue","Competitions2013","ASearch", "MediaConversion"]
  languages: ["en", "es", "de", "nl", "hu", "fr"]
  register_policy: "REGISTER_ONLY"   #this can be 'REGISTER_ONLY', 'INVITATION_ONLY' or 'HYBRID'
  advanced_search:
    instances: ["http://vishub.org"]

To set up a ViSH instance for development, this configuration should be enough and no changes should be needed.
If you are interested in the different options that can be specified in the application_config.yml file to customize and set up a ViSH instance, you can check the Setting up a ViSH instance section.

 

##Database You can use either MySQL or PostgreSQL to set up the database.
Just follow the instructions of the corresponding section: Database with MySQL or Database with PostgreSQL.
After that, remember to read the 'Set up the database' section.

##Database with MySQL

Enter in mysql:

mysql.server start 
mysql -u root -p (it will ask for the root password of the database)

To create the database for development (vish_development) execute the following sentences in the mysql console:

create database vish_development;

If we do not use the root user we will have to give access rights for the user that will access the database. Replacing "user" by your user:

grant all privileges on vish_development.*
to "user"@"localhost"
identified by ""
with grant option;

Exit mysql

quit;

Copy the file /config/database.yml.example to config/database.yml.

cp config/database.yml.example config/database.yml

The config/database.yml file will look like this:

development:
  adapter: mysql2
  database: vish_development
  encoding: utf8
  username: root
  password:
  socket: /tmp/mysql.sock

Now, edit the file to fit your configuration.
Check that the username corresponds to the user that you have configured (either root or your user) and enter the password (if any).

##Database with PostgreSQL First off, you have to install postgreSQL:

sudo apt-get install postgresql postgresql-contrib

Then, you have to create a user in the postgreSQL console. To create a user 'postgres' with password 'password' execute the following commands:

psql postgres -U YOURUSERNAME (to enter in the postgreSQL console)  
CREATE ROLE vish_dev WITH CREATEDB LOGIN PASSWORD 'yourpassword';

Now, execute the following command in the postgreSQL console to make your user superuser. This way, the 'vish_dev' user will have access rights to the databases.

ALTER USER vish_dev WITH superuser;

Afterwards, we create the databases needed.

CREATE DATABASE vish_development OWNER vish_dev;
CREATE DATABASE vish_test OWNER vish_dev;
CREATE DATABASE vish_production OWNER vish_dev;
\q (exit from postgreSQL console)

Copy the file /config/database.yml.example to config/database.yml.

cp config/database.yml.example config/database.yml

Comment the block preceded by the line '# MySQL setup (default)' and uncomment the block preceded by the line '# PostgreSQL setup'. The config/database.yml file should look like this:

development:
 adapter: postgresql
 encoding: unicode
 host: localhost
 username: vish_dev
 password: yourpassword
 database: vish_development
 pool: 5

Now, edit the file to fit your configuration.
Check that the username corresponds to the user that you have configured in the postgreSQL console and enter the password.

##Set up the database Load the database scheme and apply the database migrations executing the following commands:

bundle exec rake db:schema:load
bundle exec rake db:migrate

 

##Install the search engine
ViSH uses Sphinx as search engine. Before start the ViSH application, we need to install it.

Install version 2.1.5 from source http://sphinxsearch.com/downloads/archive/ . (configure, make, make install)

To set up the Sphinx configuration execute the following commands in the ViSH folder:

bundle exec rake ts:index
bundle exec rake ts:config

Finally, to initiate the search engine execute one of the followings commands:

a) bundle exec rake ts:rebuild (stop, index and start)
b) bundle exec rake ts:start (just start)

#MAC OS X HIGH SIERRA special steps

  • Remove lines "sql_attr_uint = id" from the file development.sphinx.conf
  • Index Sphinx with the command: bundle exec rake ts:index INDEX_ONLY=true

 

##Populate the database

You must execute the following command in order to populate the database with essential data.

bundle exec rake db:install

After this, your local ViSH instance will be ready for development.
The database will be almost empty. It will only store two users: a 'demo' user and one administrator.
The crendentials for the demo user will be: email 'demo@vishub.org' and password 'demonstration'.
The credentials for the admin user will be: email 'admin@vishub.org' and password 'demonstration'.

Optionally, you may populate the database with random data by executing the following command:

 bundle exec rake db:populate

 

##Start local server for development

Start the server executing:

bundle exec rake ts:rebuild
rails s

Check that it is working with a web browser (preferably Firefox or Chrome).
Open http://localhost:3000.
Remember that you can log in using the 'demo' user (email 'demo@vishub.org' and password 'demonstration').

The above command will start a server with only one thread. If you want to start a ViSH server in development with several threads you can use the following command:

bundle exec unicorn -p 3000 -c config/unicorn.rb

By default this will start a server with 3 threads, but you can change the quantity through the WEB_CONCURRENCY environment variable, or by modifying directly the config/unicorn.rb file.