Show More
Commit Description:
Update README.rdoc
Commit Description:
Update README.rdoc
File last commit:
Show/Diff file:
Action:
README.rdoc | 134 lines | 5.4 KiB | text/plain | TextLexer |
== 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
The detail of each step are provided as follows.
=== Install MySQL 5
Install MySQL server for the server.
$ 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.
sudo mysql -u root
mysql> create database DATABASENAME;
Query OK, 1 row affected (0.00 sec)
mysql> grant all privileges on grader.* 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)
=== Install RVM
Since Ubuntu has dedicated package for RVM we will use that. Just follow instruction given in https://github.com/rvm/ubuntu_rvm. For your convenience, the step are reproduced here.
First, we install necessary package for installing RVM.
$ sudo apt install software-properties-common
Second, we add the custom PPA, update the system and install RVM.
$ sudo apt-add-repository -y ppa:rael-gc/rvm
$ sudo apt-get update
$ sudo apt-get install rvm
This is very important. You have to logout and login again since RVM change a lots of system.
=== Install necessary package
$ sudo apt install libmysql-dev default-jdk unzip nodejs php7.2-cli apache2 dirmngr gnupg apache2-dev
curl build-essential
=== Install cafe-grader
First, ensure that RVM is installed correctly.
If instead of this you get the following error, it is very likely that you have not use bash --login.
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-ubuntu-18.04.sh
cafe@grader:~$ . ./install-ubuntu-18.04.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 http://localhost:3000/. You should try logging in to the system and verify that it is actually work.
cafe@grader:~/cafe_grader/web$ rails s
We are almost done. The last step is to set up apache and Phusion so that cafe-grader is served by apache.
=== Deploy cafe-grader on Phusion passenger via apache
Basically, we will follow the instructions given in https://www.phusionpassenger.com/library/walkthroughs/deploy/ruby/ownserver/apache/oss/bionic/install_passenger.html, which devided into two parts: Installing Passenger and deploying the app.
Installing Passenger as a mod for apache 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
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 site config file of the apache 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