SYZOJ中文安装指南
Made By:Spaceskynet
Thanks to other developers.
测试系统 Ubuntu-17.04

PS(全局变量):
[syzoj2 path] = 您git的syzoj的路径;
[syzoj-judge path] = 您git的syzoj-judge的路径
系统要求
1.node >=6.0.0 (node.js)
2.npm
3.p7zip-all && node-7z
4.boost库(c++)
安装node.js和npm
First(apt):
大家都知道
apt install nodejs
apt install npm
Second(更新node):
apt总有毒,node版本4.x.x,不升级没办法。
全局安装n模块
sudo npm install -g n
升级node.js到最新稳定版
sudo n stable
查看本机的node.js版本
node -v
Third(更新npm源):
npm是个好东西,但国内安装依赖太慢,所以对于国内用户,cnpm挺不错。
但也可以直接给npm配置taobao镜像的registry,也不是非得装cnpm。
npm config set registry https://registry.npm.taobao.org
然后直接用npm install gulp less --save-dev,就是从taobao镜像拿包了。
安装p7zip-all和node-7z
p7zip-all是配合node-7z依赖的系统解压缩软件(记住一定要安装完整版,因为还有一个p7zip,安装这个上传数据会报错)
Fisrt:
apt install p7zip-all
Second:
cd [syzoj2 path]
npm install node-7z
安装boost库
用于编译judge,
同上,这个玩意也有all与无all之分
sudo apt-get install libboost-all-dev --fix-missing
安装syzoj
Git Source-File
git clone https://github.com/syzoj/syzoj
cd syzoj
Config
将[syzoj2 path]下的 config-example.json 复制为 config.json, 然后根据您的需要修改.
cp config-example.json config.json
config.json
{
"title": "SYZOJ",//oj名
"hostname": "127.0.0.1",//web端ip
"port": "5283",//web端端口
"db": { //如使用sqlite,则不用修改
"database": null,//如使用mysql,改为mysql的数据库名还有
"username": null,//用户名
"password": null,//密码
"host": null,//和地址
"dialect": "sqlite",//并将此改为mysql
"storage": "syzoj.db"//并将npm install后(稍后使用)生成的syzoj.db文件导入mysql中,并设为null
},
"register_mail": {//SMTP邮件验证
"enabled": true,//建议设为false
"address": "test@test.domain",
"key": "test"
},
"upload_dir": "uploads",
"default": {
"problem": {
"time_limit": 1000,
"memory_limit": 256
},
"user": {
"show": true
}
},
"limit": {//时空等最大限制
"time_limit": 10000,
"memory_limit": 1024,
"data_size": 209715200,
"testdata": 209715200,
"submit_code": 102400,
"submit_answer": 10485760,
"custom_test_input": 20971520,
"testdata_filecount": 5
},
"page": {//题库页面设置
"problem": 50,
"problem_statistics": 10,
"judge_state": 10,
"ranklist": 20,
"discussion": 10,
"article_comment": 10,
"contest": 10,
"edit_contest_problem_list": 10,
"edit_problem_tag_list": 10
},
"languages": {//语言配置
"cpp": {
"show": "C++",
"highlight": "cpp",
"version": "GCC 5.4.0",
"editor": "c_cpp"
},
"cpp11": {
"show": "C++11",
"highlight": "cpp",
"version": "GCC 5.4.0",
"editor": "c_cpp"
},
"csharp": {
"show": "C#",
"highlight": "csharp",
"version": "MCS 4.8.0.0, Mono 4.8.0",
"editor": "csharp"
},
"c": {
"show": "C",
"highlight": "c",
"version": "GCC 5.4.0",
"editor": "c_cpp"
},
"vala": {
"show": "Vala",
"highlight": "vala",
"version": "Vala 0.30.1, GCC 5.4.0",
"editor": "vala"
},
"java": {
"show": "Java",
"highlight": "java",
"version": "GCC 5.4.0",
"editor": "java"
},
"pascal": {
"show": "Pascal",
"highlight": "pascal",
"version": "FPC 3.0.0",
"editor": "pascal"
},
"lua": {
"show": "Lua",
"highlight": "lua",
"version": "Lua 5.2.4",
"editor": "lua"
},
"luajit": {
"show": "LuaJIT",
"highlight": "lua",
"version": "LuaJIT 2.0.4",
"editor": "lua"
},
"python2": {
"show": "Python 2",
"highlight": "python",
"version": "CPython 2.7.12",
"editor": "python"
},
"python3": {
"show": "Python 3",
"highlight": "python",
"version": "CPython 3.5.2",
"editor": "python"
},
"nodejs": {
"show": "Node.js",
"highlight": "js",
"version": "7.7.3",
"editor": "javascript"
},
"ruby": {
"show": "Ruby",
"highlight": "ruby",
"version": "2.3.1",
"editor": "ruby"
},
"haskell": {
"show": "Haskell",
"highlight": "haskell",
"version": "GHC 7.10.3",
"editor": "haskell"
},
"ocaml": {
"show": "OCaml",
"highlight": "ocaml",
"version": "Ocamlbuild 4.02.3",
"editor": "ocaml"
},
"vbnet": {
"show": "Visual Basic",
"highlight": "vbnet",
"version": "VBNC 0.0.0.5943, Mono 4.8.0",
"editor": "vbscript"
}
},
"links": [//友链
{
"title": "LibreOJ",
"url": "https://loj.ac/"
}
],
"session_secret": "233",//加密Token,自定义,建议复杂些
"judge_token": "233"//记得将judge配置中webtoken一同修改
}
Second(安装):
npm install or yarn
耐心等待后……
使用npm start启动web端
在浏览器中输入config.json中的[hostname]:[port],此时,您应该可以看见syzoj web端正常运行。
然后注册用户,如想成为超级管理员,只有直接修改数据库这一方法。
在数据库中,user表中is_admin属性决定某一用户是否为管理员。
在sqlite中,您可以使用下列语句获取root权限。
cd [syzoj2 path]
sqlite3 syzoj.db
会进入sqlite
UPDATE user SET is_admin = '1' WHERE username='[Your username]';
其它数据库也一样,只要将is_admin属性修改为'1'即可。
其它
将 SYZOJ 设置为bash快速启动.
vim [syzoj2 path]/runsyzoj
将 runsyzoj 文件改为如下代码.
#!/bin/bash
cd [syzoj2 path]
npm start > log.txt 2>&1
请改为自己的 [syzoj2 path].
将 SYZOJ 设置为系统服务
添加 /etc/systemd/system/syzoj.service 文件,加入如下内容.
[Unit]
Description=SYZOJ Online Judge
After=network.target
[Service]
Type=simple
PIDFile=/run/syzoj.pid
WorkingDirectory=[syzoj2 path]
ExecStart=[syzoj2 path]/runsyzoj
StandardOutput=null
StandardError=null
[Install]
WantedBy=multi-user.target
请改为自己的 [syzoj2 path].
使用方法
Start
systemctl start syzoj
Stop
systemctl stop syzoj
Restart
systemctl restart syzoj
安装syzoj-judge
Git Source-File
git clone https://github.com/syzoj/syzoj-judege2
cd syzoj-judege2
内核需求
您需要在内核中开启 memory swap account (默认在 Debian 8/ubuntu中未开启) 。您可以通过检查它的存在来验证这一点: /sys/fs/cgroup/memory/memory.memsw.usage_in_bytes
如果该文件不存在,那么您可能必须使用grub打开该文件。
将 swapaccount=1 添加到/etc/default/grub文件中 GRUB_CMDLINE_LINUX_DEFAULT 选项.
就像这样:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash cgroup_enable=memory swapaccount=1"
然后保存后运行下列命令重启:
update-grub && reboot
下载更多的依赖
syzoj-judege2是基于沙盒的评测系统,所以您需要从Menci的服务器下载沙盒评测系统(建议在windows上用迅雷下好了再导入评测服务器)
Linux:
wget ip1.menci.moe/sandbox-rootfs.tar
windows:
http://ip1.menci.moe/sandbox-rootfs.tar //下载链接
解压沙盒服务器
tar -xvf sandbox-rootfs.tar
将沙箱服务器移动到您想要的路径(可选)(建议放入syzoj-judge2目录下)
mv sandbox-rootfs [Your Path]
正式安装
切换目录:
cd syzoj-judge2
然后通过下列命令安装:
npm install
cd node_modules/syspipe
npm install
cd ../..
npn run build
cp instance-config-example.json instance-config.json
cp shared-config-example.json shared-config.json
或者 yarn (如果您已经安装yarn)
设置
修改 instance-config.json shared-config.json
一些例子:
| 属性名 | 修改为 | Example |
|---|---|---|
| sandboxRoot | 您的 sandbox-rootfs 路径 | "sandbox-rootfs" |
| WorkingDirectory | 评测临时文件储存目录 | "sandbox" |
| sandboxCgroup | 沙盒名称 | "syzoj-1" |
| webToken | web端config.json中 judge_token | "233" |
运行 SYZOJ-JUDGE
cd [syzoj-judge path]
node lib/index.js -s shared-config.json -i instance-config.json > jlog.txt 2>&1
在web端提交代码,此时应该成功评测。
其它
将 SYZOJ-JUDGE 设置为bash快速启动.
vim [syzoj-judge path]/runjudge
将 runjudge 文件改为如下代码.
#!/bin/bash
cd [syzoj-judge path]
node lib/index.js -s shared-config.json -i instance-config.json > jlog.txt 2>&1
请改为自己的 [syzoj-judge path].
将 SYZOJ-JUDGE 设置为系统服务
添加 /etc/systemd/system/syzoj-judge.service 文件,加入如下内容.
[Unit]
Description=SYZOJ Judge Daemon
After=network.target
[Service]
Type=simple
PIDFile=/run/syzoj-judge.pid
WorkingDirectory=[syzoj-judge path]
ExecStart=[syzoj-judge path]/runjudge
StandardOutput=null
StandardError=null
[Install]
WantedBy=multi-user.target
请改为自己的 [syzoj-judge path].
使用方法
Start
systemctl start syzoj-judge
Stop
systemctl stop syzoj-judge
Restart
systemctl restart syzoj-judge
PS
到这儿,syzoj应该就安装成功了,Enjoy it!
如果您还想折腾,您也可以试试在docker中安装syzoj(UOJ便是如此),方便备份数据。
Thanks to other developers.
如有问题,欢迎反馈……
开放合作共同促进是OI的传统,同时也是开源项目的一贯做法,正式因为开放才使得大家可以有更多的学习资源,希望大家共同交流,共同进步! -----By:Chenyao
SYZOJ中文安装指南的更多相关文章
- android studio1.0 for Mac环境搭建与demo运行(手动下载gradle,科学上google) 转载
http://blog.csdn.net/allenffl/article/details/41957907 官网下载 http://developer.android.com/sdk/install ...
- 如何在Linux上面安装GCC 4.1.2
安装步骤: 1.首先下载GCC 4.1.2的source code package: $ wget http://mirrors.ustc.edu.cn/gnu/gcc/gcc-4.1.2/gcc-4 ...
- wazuh官方安装指南(中文译版本)
安装Wazuh服务器 Wazuh服务器可以安装在任何类型的Unix操作系统上.最常见安装在Linux上.如果可以为您的系统提供自动化脚本,则安装过程会更容易,但是,从源码构建和安装也非常简单. 通 ...
- 全新 Mac 安装指南(通用篇)(推荐设置、软件安装、推荐软件)
注:本文将会不定期维护与更新,有需要的朋友请在 Github 上订阅该条 Issues:<全新 Mac 安装指南(通用篇)>. 在 Mac 电脑上只用 Windows 操作系统的同学请看到 ...
- ArchLinux安装指南
将ArchLinux作为进阶Linux发行版,主要看重滚动更新和深入理解Linux的安装过程. 由于是新手,所以先选择在公司电脑上用VMware来安装.然后渐进到借助U盘在win10笔记本上安装双系统 ...
- Ubuntu14.04安装中文输入法以及解决Gedit中文乱码问题
1 设置中文显示环境 1. 打开System Settings 2. 打开Personal-> Language Support. 会弹出如下对话框,提示你“语言支持没安装完整”. 点击“Rem ...
- Ubuntu14.04安装中文输入法以及解决Gedit中文乱码问题[转载]
转载自:http://www.cnblogs.com/zhcncn/p/4032321.html 写在前面:解决gedit 在txt文件格式出现乱码的问题,在我自己的操作中是需要把系统设置成中文显示环 ...
- OpenERP 7.0 中文报表PDF乱码(WindowsXP)
OpenERP默认安装输出的PDF中文报表都是一些方块: 此问题可以通过oecn_base_fonts模块解决: 更多关于oecn_base_fonts的信息请参考: 1. OpenERPv7.0 中 ...
- Visual C++2010开发权威指南 中文高清PDF - VC.NET
第一部分 Visual C++ 2010开发与新特性第1章 Visual C++ 2010开发环境简介 11.1 Visual C++ 2010简介 11.2 Visual C++ 2010下 ...
随机推荐
- S2-052 漏洞复现
Structs2框架已知的漏洞编号如下: S2-005 S2-009 S2-016 (含S2-013) S2-019 S2-020 S2-021 S2-032 S2-037(含S2-033) DevM ...
- MongoDB 学习笔记之 $or与索引关系
$or与索引关系: 对leftT集合的timestamp创建索引 执行$or语句:db.leftT.find({$or: [{ "timestamp" : 5},{"ag ...
- 数据表管理admin
知识预览 admin组件使用 admin源码解析 回到顶部 admin组件使用 Django 提供了基于 web 的管理工具. Django 自动管理工具是 django.contrib 的一部分.你 ...
- SQL SERVER数据库三种数据插入方式
数据插入:INSERT INTO A(CBM,CMC) VALUES('1','测试')--单条数据插入INSERT INTO A(CBM,CMC)SELECT '1','测试'--单条数据插入INS ...
- 网络编程java
网络编程 1.网络编程概述(1).C/S结构:指客户端与服务端结构,常见程序QQ;(2).B/S结构:指浏览器和服务器的结构;2.网络编程的三要素:*IP地址*端口号*通信协议(UDP/TCP) *I ...
- 移动端自动化测试Appium 从入门到项目实战Python版☝☝☝
移动端自动化测试Appium 从入门到项目实战Python版 (一个人学习或许会很枯燥,但是寻找更多志同道合的朋友一起,学习将会变得更加有意义✌✌) 说到APP自动化测试,Appium可是说是非常流 ...
- java架构之路-(Redis专题)Redis的高性能和持久化
上次我们简单的说了一下我们的redis的安装和使用,这次我们来说说redis为什么那么快和持久化数据 在我们现有的redis中(5.0.*之前的版本),Redis都是单线程的,那么单线程的Redis为 ...
- Windows系统调用中API的3环部分(依据分析重写ReadProcessMemory函数)
Windows内核分析索引目录:https://www.cnblogs.com/onetrainee/p/11675224.html Windows系统调用中API的3环部分 一.R3环API分析的重 ...
- windows 7 专业版 64位 无法安装.Net 4.7版本解决方案
什么暂停windows update,改文件夹,再恢复windows update等等方法都试了,不行之后就觉得这才是终极解决方案. 不管你是win 7什么版本,你只需要下载安装对应系统的Window ...
- Google研发面试题
今天很开心找到了一个很不错的研发面试题,很考验临时反应能力,特地拿出来和大家分享一下此题以及自己做该题的心得体会!!! 题目: 总共有12个外表都一样的金属球,其中有11个球的重量是相同的,1个球的重 ...