Skip to content

ViSH Installation Linux

Aldo Gordillo edited this page Apr 16, 2020 · 6 revisions

ViSH Installation

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

  • A computer with:
    • Ubuntu 14.04 (also works with Ubuntu 12.04)
    • Internet connection

Install ruby2.x and git:

sudo apt-get install git-core
sudo apt-add-repository ppa:brightbox/ruby-ng
sudo apt-get update
sudo apt-get install ruby2.2

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

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.
To do that, go to Settings -> SSH keys -> Add SSH Key in your account, and save your public key.

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

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.

sudo apt-get install ruby2.2-dev libxml2-dev libxslt-dev libmagickcore-dev libmagickwand-dev libmysqlclient-dev libsqlite3-dev imagemagick libpq-dev nodejs

Now enter in the folder ViSH and execute the following commands:

cd vish  
gem install bundler -v "=1.8.0" 
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: "[email protected]"
  main_mail: "[email protected]"
  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

First off, you should install mysql and the mysql ruby library.

sudo apt-get install mysql-server libdbd-mysql-ruby

Enter in mysql:

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: /var/run/mysqld/mysqld.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 'vish_dev' with password 'yourpassword' execute the following commands:

sudo -u postgres psql (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.

sudo apt-get install sphinxsearch

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)

 

##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 '[email protected]' and password 'demonstration'.
The credentials for the admin user will be: email '[email protected]' 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 '[email protected]' 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.