Ejudge Installation on Ubuntu 18.04

Ejudge - this is a system for conducting various events that require automatic program judging.

The system allows running tournaments with automatic problem judging. Such as: icpc, ioi and more. You can hold several tournaments at the same time.

One of the advantages of this system over other judging systems is that Ejudge has good integration with polygon and remains high-performance even with a large number of participants.

On the other hand, the disadvantage of this system for me was the high entry threshold and complex documentation.

All commands that start with sudo are run as root or with sudo rights

You can read more details from these resources

1. Preparing the system

1.1 Installing a locale

sudo locale-gen en_US.UTF-8 ru_RU.UTF-8 kk_KZ.UTF-8
sudo update-locale

1.2 Installing the necessary apps and libraries

sudo apt-get update

sudo apt-get install -y software-properties-common

sudo apt-get install -y --allow-unauthenticated \
                       wget locales ncurses-base libncurses-dev libncursesw5 \
                       libncursesw5-dev expat libexpat1 libexpat1-dev \
                       zlib1g-dev libelf-dev mysql-client-5.7 libmysqlclient-dev \
                       g++ gawk apache2 gettext fpc mc openjdk-8-jdk-headless \
                       libcurl4-openssl-dev libzip-dev uuid-dev bison flex \
                       mono-devel mono-runtime mono-vbnc perl python python3 \
                       sendmail

1.3 Installing MariaDB

MariaDB can be replaced with MySQL

sudo apt-get install -y mariadb-server mariadb-client

1.4 Configuring MariaDB

Run mysql

sudo mysql

Create user ejudge with password, example: X93ZTC3GJm, and give the necessary rights.

CREATE USER 'ejudge'@'%' IDENTIFIED BY 'X93ZTC3GJm';
GRANT USAGE ON * . * TO 'ejudge'@'%' IDENTIFIED BY 'X93ZTC3GJm' 
WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
CREATE DATABASE IF NOT EXISTS `ejudge` ;
GRANT ALL PRIVILEGES ON `ejudge` . * TO 'ejudge'@'%';
exit;

1.5 Apache2 installation

sudo rm /etc/apache2/sites-enabled/*

Create configuration file for Apache2

sudo bash -c 'cat > /etc/apache2/sites-enabled/ejudge.conf' << EOF
<VirtualHost *:80>
    DocumentRoot /var/www/ejudge/htdocs

    ScriptAlias /cgi-bin/ "/var/www/ejudge/cgi-bin/"

    <Directory "/var/www/ejudge/cgi-bin">
        Options +ExecCGI +FollowSymLinks +Includes
        AllowOverride None
        Require all granted
    </Directory>

    <Directory "/var/www/ejudge/htdocs">
        Require all granted
    </Directory>

    ErrorLog /var/log/apache2/error.log
    CustomLog /var/log/apache2/access.log combined

</VirtualHost>

EOF

Activate cgi module and restart apache2

sudo a2enmod cgi 
sudo service apache2 restart

1.6 Creating an ejudge group and user

sudo groupadd ejudge
sudo useradd ejudge -r -s /bin/bash -g ejudge

1.7 Creating directives

EJUDGE_HOME

sudo mkdir -p /home/ejudge
sudo chown ejudge:ejudge /home/ejudge
sudo chmod 0755 /home/ejudge

JUDGES_DIR and WORK_DIR

sudo mkdir -p /home/judges /home/judges/test_work
sudo chown ejudge:ejudge /home/judges /home/judges/test_work
sudo chmod 0755 /home/judges /home/judges/test_work

CGI-BIN-DIR and HTDOCS-DIR

sudo mkdir -p /var/www/ejudge/cgi-bin
sudo mkdir -p /var/www/ejudge/htdocs
sudo chmod 0777 /var/www/ejudge/cgi-bin /var/www/ejudge/htdocs

2. System installation

Futher run as ejudge user

To change user to ejudge:

sudo su ejudge

2.1 Downloading and unpacking

cd /home/ejudge
wget -O ejudge.tar.gz --no-check-certificate http://www.ejudge.ru/download/ejudge-3.8.0.tgz

tar -xvf ejudge.tar.gz 
rm ejudge.tar.gz

2.2 Configuring Ejudge

cd /home/ejudge/ejudge

./configure --prefix="/home/ejudge/inst-ejudge" \
            --enable-contests-home-dir="/home/judges" \
            --with-httpd-cgi-bin-dir="/var/www/ejudge/cgi-bin" \
            --with-httpd-htdocs-dir="/var/www/ejudge/htdocs" \
            --enable-ajax \
            --enable-charset=utf-8 \
            --with-primary-user="ejudge" \
            --with-exec-user="ejudge" \
            --with-compile-user="ejudge" 
make
make install

If you changes parameters: --with-primary-user, --with-exec-user, --with-compile-user, then run the next code. This program will set the necessary permissions for privileged executable files.

Must runs as the root

cd home/ejudge/inst-ejudge/bin/
sudo ./ejudge-suid-setup

2.3 Setting

Run as the ejudge user

cd /home/ejudge/ejudge/
./ejudge-setup

Change settings to correct ones:

  1. Change Testing working dir to /home/judges/test_work
  2. Change login and pass from MySQL

Save script as ejudge-install.sh

2.4 Installation

Run installation as the root user

sudo /home/ejudge/ejudge/ejudge-install.sh

3. Running

cd /home/ejudge/inst-ejudge/bin
./ejudge-upgrade-web

./ejudge-control start

The service will be available at http://localhost/cgi-bin/serve-control