Skip to content

Installation

tobiichi3227 edited this page Dec 15, 2025 · 10 revisions

Download

git clone https://github.com/Tfcis/NTOJ

Install

Docker

  1. Install docker and docker-compose.
  2. Copy scripts/.env.example to .env and setup.
  3. docker compose up -d and enjoy TOJ on port 5500.

Env Configuration

NTOJ will store some permanent data in /srv/ntoj like database, cache, problem, challenge code.

If you want to change this folder, please modify docker-compose.yml

DB_PASSWORD=DB_PASSWORD
UNLOCK_PASSWORD=UNLOCK_PASSWORD
ADMIN_NAME=admin
ADMIN_MAIL=admin@admin
ADMIN_PASSWORD=admin1234
SITE_TITLE="New TNFSH Online Judge"
TIMEDELTA=8
BASE_URL="/"

If BASE_URL not equal to /, you need set web proxy like above.

# Assume BASE_URL="/oj"
location /oj {
    rewrite ^/oj/(.*) /$1 break;
    proxy_pass http://localhost:5500;
    proxy_read_timeout 14400s;
    proxy_http_version 1.1;
    proxy_set_header X-Real-Ip $remote_addr;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
}

Installation Script

This script is tested on Ubuntu 22.04 LTS, 24.04 LTS and Debian 12.

Installation Configuration

Please create a .env file in the scripts directory.
Refer to the example file at scripts/.env.example. The .env file should look like this:

INSTALL_DIR=/srv # Installation directory
PORT=5500
REDIS_DB=1
REDIS_HOST=localhost
DB_NAME=ntoj
DB_USERNAME=ntoj
DB_PASSWORD=DB_PASSWORD
DBHOST_OJ=localhost
UNLOCK_PASSWORD=UNLOCK_PASSWORD
ADMIN_NAME=admin
ADMIN_MAIL=admin@admin
ADMIN_PASSWORD=admin1234 # The password must be more than eight characters long and include both letters (in any case) and numbers.
SITE_TITLE="TOJ"
TIMEDELTA=8
BASE_URL="/"

If BASE_URL not equal to /, you need set web proxy like above.

# Assume BASE_URL="/oj"
location /oj {
    rewrite ^/oj/(.*) /$1 break;
    proxy_pass http://localhost:5500;
    proxy_read_timeout 14400s;
    proxy_http_version 1.1;
    proxy_set_header X-Real-Ip $remote_addr;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
}

Installation

cd scripts
# Set parameters
./install.sh

Start NTOJ

cd your_install_dir/ntoj
./runserver.sh # You can use tmux or similar tools

The default port is set to 5500.

Clone this wiki locally