Installing cafe-grader can be done in the following steps.
-
Set up database. We need MySQL 5 database name, username and password.
-
Install RVM. cafe-grader runs on Ruby on Rails and the best way to install it is to use RVM.
-
Install necessary package for the system
-
Install cafe-grader from github
-
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.
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> grant all privileges on DATABASENAME.* to USERNAME@localhost identified by 'PASSWORD'; Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)
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
This is very important. You have to logout and login again since RVM change a lots of system.
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.
cafe@grader:~$ sudo apt install libmysqlclient-dev default-jdk unzip nodejs php-cli apache2 dirmngr gnupg apache2-dev
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 WEBrick. 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 WEBrick 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.
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.
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’