本文最后更新于:星期四, 二月 3日 2022, 9:15 晚上
                
              
            
            
              本文参考于:https://github.com/cn-xcpc-tools/cn-xcpc-docs 
腾讯云学生机 
Ubuntu Server 18.04.1 LTS 64位 
 
sudo apt-get upgrade && sudo apt-get update
sudo apt install gcc g++ make zip unzip mariadb-server \
安装时选择 apache2
sudo apt install libcurl4-gnutls-dev libjsoncpp-dev libmagic-dev
domjudge-7.1.1.tar.gz 
cd Downloads
tar -zxvf domjudge-7.1.1.tar.gz
cd domjudge-7.1.1
cd /opt/ domjudge/domserver
cd /opt/domjudge/domserver
现在你应该可以访问 http://127.0.0.1/domjudge 或者公网并使用用户名 admin 与 /opt/domjudge/domserver/etc/initial_admin_password.secret 内生成的密码登录 domjudge 后台了。
编辑 /etc/mysql/conf.d/mysql.cnf,追加以下内容:
[mysqld]
其中 max_allowed_packet 数值改成两倍于题目测试数据文件的大小,innodb_log_file_size 数值改成十倍于题目测试数据文件的大小。
sudo systemctl restart mysql
编辑 /opt/domjudge/domserver/etc/apache.conf,取消以下几行内容前的注释:
<IfModule mod_php7.c>
编辑 /etc/php/7.2/apache2/php.ini,搜索 date.timezone 关键字,取消其行前注释,并将其值设为 Asia/Shanghai。搜索 max_execution_time 关键字,将其值由30改为300,防止生成队伍密码时 PHP 执行超时。
sudo systemctl restart apache2
编辑 /etc/apache2/apache2.conf,搜索 KeepAlive 关键字,将其值设为 Off,并在其后新增一行内容:
sudo systemctl restart apache2
sudo apt-get upgrade && sudo apt-get update
cd Downloads
这会将 judgehost 安装在 /opt/domjudge/judgehost 里。
useradd -d /nonexistent -U -M -s /bin/false domjudge-run#  如果 judgehost 拥有多个 CPU 核心,你可以添加额外的用户来支持绑定 #  不同的 judgehost 进程到不同的 CPU 核心上,如下: #  ... 如果有更多的 CPU 核心,请自行添加更多的用户 
将 /opt/domjudge/judgehost/etc/sudoers-domjudge 复制到 /etc/sudoers.d/ 目录下。
sudo cp /opt/domjudge/judgehost/etc/sudoers-domjudge /etc/sudoers.d/
使用 vim 等文本编辑器编辑 /opt/domjudge/judgehost 目录下 etc/restapi.secret 这个文件。文件的格式为:
default http://example.edu/domjudge/api/  judgehosts  MzfJYWF5agSlUfmiGEy5mgkfqU
注意不要有空行
格式为 endpoint api_url username password ,endpoint 可以保持不变,api_url 根据 judgeserver 的地址进行修改,username 和 password 要与 domserver上的 etc/restapi.secret 保持一致。
使用 vim 等文本编辑器编辑 ~/domjudge/judgehost/bin/dj_make_chroot 脚本,将 ubuntu 镜像改为国内源。(第 172 行)
#  Ubuntu mirror, modify to match closest mirror 
修改之后保存并运行此脚本(bash 运行)。这一步会从源上下载必要的软件包,所以请耐心等待。
使用 vim 等文本编辑器编辑 /etc/default/grub 这个文件,对其中的这一行做如下修改:
GRUB_CMDLINE_LINUX_DEFAULT="quiet cgroup_enable=memory swapaccount=1"
如果下面的步骤仍然报错 那就修改
GRUB_CMDLINE_LINUX="quiet cgroup_enable=memory swapaccount=1"
然后执行:
之后重启计算机 。
如果需要使用cgroup,则每次重启之后都要运行 /opt/domjudge/judgehost/bin/create_cgroups/opt/domjudge/judgehost/bin/judgedaemon 即可启动,若提示 error: Call to undefined function curl_init(),则可以安装 php-curl 解决
如果想要断开连接并且还可以正常使用判题机,这样来
bash /opt/domjudge/judgehost/bin/create_cgroups
退出连接的时候记得用exit,不要直接关闭 到这里,domjudge就可以正常投入使用了。
使用 vim 等文本编辑器在 /lib/systemd/system 下新建一个文本文件叫做 create-cgroups.service,写入下列内容:
[Unit]
在 /lib/systemd/system 下再新建一个文本文件叫做 domjudge-judgehost@.service ,写入下列内容: 注意 User=<username> 要用自己编译 judgehost 时的用户名,因为 /etc/sudoers.d/sudoers-domjudge 列表里是当时的用户
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 [Unit]
在 /etc/rsyslog.d/ 下新建一个文本文件叫做 judgehost.conf,写入下列内容:
:programname, isequal, "judgehost-0" /var/log/judgehost/judgehost-0.log
重启日志服务,启动四个 judgehost:
sudo systemctl restart rsyslog
judgedaemon的日志会保存在 /var/log/judgehost 下
一些杂项
script 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 ./configure --prefix=/opt/domjudge --with-baseurl=127.0.0.1# 重启judge # 设置开机启动