事情是这样的
于是乎老师给了我一台 Digital Ocean 的主机,
操作系统是 Ubuntu 18.04 LTS。
上来先配置了一下 root 的密码,
然后创建了新用户:junyi
将 junyi 加到 sudoers 里。
之后apt-get update,
打开DOMjudge官网,按照Installation 说明进行安装,
sudo apt install gcc g++ make zip unzip mariadb-server
sudo apt install apache2 php php-cli libapache2-mod-php php-zip
sudo apt install php-gd php-curl php-mysql php-json php-xml php-mbstring
sudo apt install acl bsdmainutils ntp phpmyadmin python-pygments
sudo apt install libcgroup-dev linuxdoc-tools linuxdoc-tools-text
sudo apt install groff texlive-latex-recommended texlive-latex-extra
sudo apt install texlive-fonts-recommended texlive-lang-european
To enable the command-line submit client, also add:
sudo apt install libcurl4-gnutls-dev libjsoncpp-dev libmagic-dev
Note that PHP modules may need to be enabled depending on your distribution. E.g. on Ubuntu run
sudo phpenmod json
On a judgehost, the following should be sufficient. The last two lines show some example compilers to install for C, C++, Java (OpenJDK), Haskell and Pascal; change the list as appropriate.
For Debian:
sudo apt install make sudo debootstrap libcgroup-dev
sudo apt php-cli php-curl php-json php-xml php-zip procps
sudo apt gcc g++ openjdk-8-jre-headless
sudo apt openjdk-8-jdk ghc fp-compiler
依赖什么的都装好之后,
下载 DOMjudge 安装包
tar -xzvf 解压,然后
cd domjudge-3.2.1
./configure --prefix=$HOME/domjudge --with-base-url=http://xxx.xxx.xxx.xxx/
(url根据自己的实际情况填写)
再然后,根据官方教程,
make domserver judgehost docs
Run make install-{domserver,judgehost,docs}
as root to install the system.
sudo ln -s $HOME/domserver/etc/apache.conf /etc/apache2/conf-available/domjudge.conf
由于缺乏Ubuntu的操作经验,我在这个网站上查到,
ubuntu 中的 httpd.conf 叫 /etc/apache2/apache2.conf
我们,先创建一个httpd.conf
然后打开apache2.conf,写入一行
Include /etc/apache2/httpd.conf
保存
编辑httpd.conf
写入一行
ServerName localhost
保存
执行命令:
sudo a2enmod rewrite
sudo a2enconf domjudge
sudo apache2ctl graceful
访问:
http://127.0.0.1/domjudge/
http://127.0.0.1/domjudge/login
(应该可以看到DOMjudge的页面)
bin/dj_setup_database genpass
bin/dj_setup_database -u root -p install
(这里应该还有MySQL安装过程,此处省略)
useradd -d /nonexistent -U -M -s /bin/false domjudge-run
cd $HOME/domjudge/judgehost/etc
sudo cp sudoers-domjudge /etc/sudoers.d
cd 到 judgehost 目录
sudo bin/dj_make_chroot
cd /etc/php/7.0/apache2/
sudo nano php.ini
date.timezone = “Asia/Shanghai”
重启 Apache 服务
sudo service apache2 restart
judgehost/bin/create_cgroups
./judgedaemon
远程发现mysql连接不上
查资料发现
/etc/mysql/mariadb.conf.d/50.client.cnf 文件中有 bind-address: 127.0.0.1
注释掉或改为 0.0.0.0 即可
安装mysql:
apt-get purge
sudo apt-get remove --purge mysql*
sudo apt-get autoremove
sudo apt-get autoclean
Delete /var/lib/mysql
sudo apt install mysql-server mysql-client
每次重启都需要运行judgehost/bin/create_cgroups,否则提交会编译错误。
简要来说,用 HTTPS 保护网络传输,用配置和密码来保护 DOMjudge server,用帐号权限(限制文件系统和网络接入资源)、chroot(隔离运行环境)、setrlimit(限制CPU、内存、进程等资源)来保护 Judgehost。
要把Apache的KeepAlive关掉
https://www.domjudge.org/pipermail/domjudge-devel/2015-March/001629.html
https://gist.github.com/ubergarm/9695532
https://www.digitalocean.com/community/questions/setting-kernel-command-line