Skip to content

nattee/cafe-grader-web

 
 

Repository files navigation

Installation

Installing cafe-grader can be done in the following steps.

  1. Set up database. We need MySQL 5 database name, username and password.

  2. Install RVM. cafe-grader runs on Ruby on Rails and the best way to install it is to use RVM.

  3. Install necessary package for the system

  4. Install cafe-grader from github

  5. Deploy cafe-grader on apache with Phusion Passenger

Very important!!! All commands should be run from a normal user.

The detail of each step are provided as follows.

1. Install MySQL 5

Install MySQL server for the server.

cafe@grader:~$ sudo apt install mysql-server

Next, we will connect to mysql as root and set up the database. You can choose your DATABASENAME, USERNAME and PASSWORD as you wish.

cafe@grader:~$ sudo mysql -u root

mysql> create database DATABASENAME;
Query OK, 1 row affected (0.00 sec)

mysql> create user USERNAME@localhost identified by 'PASSWORD';
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> grant all privileges on DATABASENAME.* to USERNAME@localhost;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

2. Install RVM

Since Ubuntu has dedicated package for RVM we will use that. Just follow instruction given in github.com/rvm/ubuntu_rvm. For your convenience, the step are reproduced here.

First, we install necessary package for installing RVM.

cafe@grader:~$ sudo apt install software-properties-common

Second, we add the custom PPA, update the system and install RVM.

cafe@grader:~$ sudo apt-add-repository -y ppa:rael-gc/rvm
cafe@grader:~$ sudo apt-get update
cafe@grader:~$ sudo apt-get install rvm

We also need to add our user to the rvm group

sudo usermod -a -G rvm $USER

This is very important.

  1. You have to reboot since RVM change a lots of system.

  2. If you are using GUI version of Ubuntu, be sure to have Gnome Terminal (or any other terminal you are using) perform login every time. This can be done by mark the check box “Run command as a login shell” in Gnome terminal or by adding –login to bash.

3. Install necessary package and nodejs

First, we install required package via apt.

cafe@grader:~$ sudo apt install git libmysqlclient-dev default-jdk unzip php-cli apache2 apache2-dev

Next, we need nodejs. Depends on your ubuntu version, the step to install correct version of nodejs differs.

3.1 Install nodejs on Ubuntu 18.04

Since nodejs that comes with ubuntu 18.04 is very outdated, we need to install it manually. This follow the method outlined in www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-18-04 under *Installing Node.js with Apt Using a NodeSource PPA*

cd ~
curl -sL https://deb.nodesource.com/setup_17.x -o nodesource_setup.sh
sudo bash nodesource_setup.sh
sudo apt install nodejs

3.2 Install nodejs on Ubuntu 20.04 or newer

cafe@grader:~$ sudo apt install nodejs

4. Install cafe-grader

First, ensure that RVM is installed correctly.

cafe@grader:~$ rvm

If you get a result similar to this.

Command 'rvm' not found, but there are 21 similar ones.

It is very likely that you have not re-login or you are using bash without –login. Please do so and re-read the installation of RVM on Ubuntu github.com/rvm/ubuntu_rvm again.

Next, we will let the install script do the work of installing cafe-grader. Please prepare the DATABASENAME, USERNAME and PASSWORD as the script will ask for that. Make sure that you run the script from the home directory of the user.

cafe@grader:~$ wget https://github.com/cafe-grader-team/cafe-grader-judge-scripts/raw/master/installer/install.sh
cafe@grader:~$ . ./install.sh

After installation is finished, grader is ready to run in development mode via Puma. We will try that by the following command which will start a grader accessible via localhost:3000/. You can try logging in to the system and verify that it is actually work.

cafe@grader:~/cafe_grader/web$ rails s

If Everything is OK, stop the Puma by Ctrl-C.

We are almost done. The last step is to set up apache and Phusion so that cafe-grader is served by apache.

5. Deploy cafe-grader on Phusion passenger via apache

This will install a Passenger mod for apache. You can start by visiting www.phusionpassenger.com/library/walkthroughs/deploy/ruby/ownserver/apache/oss/install_passenger_main.html and fllow through the guide. We have reproduce the step here for Ubuntu 18.04. For other version, please select the appropriate one on the previous link.

The deploy is divided into two parts: Installing Passenger and deploying the app.

5.1. Installing Passenger as a mod for apache via PPA and enable it.

cafe@grader:~$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 561F9B9CAC40B2F7
cafe@grader:~$ sudo apt-get install -y apt-transport-https ca-certificates
cafe@grader:~$ sudo sh -c 'echo deb https://oss-binaries.phusionpassenger.com/apt/passenger bionic main > /etc/apt/sources.list.d/passenger.list'
cafe@grader:~$ sudo apt-get update
cafe@grader:~$ sudo apt-get install -y libapache2-mod-passenger
cafe@grader:~$ sudo a2enmod passenger

cafe@grader:~$ sudo apache2ctl restart

Finally, we should check that passenger is installed correctly. Run the following command and fix anything as suggested by the command.

cafe@grader:~$ sudo /usr/bin/passenger-config validate-install

5.2. Deploying the app. First, we determine the exact location of our ruby that is installed via RVM.

cafe@grader:~$ passenger-config about ruby-command

passenger-config was invoked through the following Ruby interpreter:

Command: /home/cafe/.rvm/gems/ruby-2.3.7/wrappers/ruby
Version: ruby 2.3.7p456 (2018-03-28 revision 63024) [x86_64-linux]
To use in Apache: PassengerRuby /home/cafe/.rvm/gems/ruby-2.3.7/wrappers/ruby
To use in Nginx : passenger_ruby /home/cafe/.rvm/gems/ruby-2.3.7/wrappers/ruby
To use with Standalone: /home/cafe/.rvm/gems/ruby-2.3.7/wrappers/ruby /usr/bin/passenger start

Then, take note of the path after “Command”. For this guide, it is /home/cafe/.rvm/gems/ruby-2.3.7/wrappers/ruby

Assuming that cafe-grader is installed at /home/cafe/cafe_grader, we will edit the Apache’s site config file /etc/apache2/site-enabled/000-default.conf as follow.

<VirtualHost *:80>
    #ServerName www.example.com

    ServerAdmin webmaster@localhost
    # dont forget to change the document root
    DocumentRoot /home/cafe/cafe_grader/web/public

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

    # add Passenger
    PassengerRuby /home/cafe/.rvm/gems/ruby-2.3.7/wrappers/ruby

    # our cafe-grader app
    <Directory /home/cafe/cafe_grader/web/public>
            Allow from all
            Options -MultiViews
            Require all granted
    </Directory>
</VirtualHost>

Be noted that we make 3 modifications: 1) change DocumentRoot, 2) add PassengerRuby option and add 3) Directory directive As the last step, we restart apache again and the site is ready to be used.

cafe@grader:~$ sudo apache2ctl restart

Now it is done, you can login to the grader with user ‘root’ and password ‘ioionrails’

About

This is a web-based component of Cafe Grader. It is written in Ruby, using Ruby on Rails web framework.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 68.7%
  • Haml 24.5%
  • SCSS 2.6%
  • JavaScript 1.7%
  • HTML 1.2%
  • CSS 1.0%
  • CoffeeScript 0.3%