SYZOJ中文安装指南
来源:互联网 发布:成都餐饮网络建设电话 编辑:程序博客网 时间:2024/06/08 19:48
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/syzojcd 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
会进入sqliteUPDATE user SET is_admin = '1' WHERE username='[Your username]';
其它数据库也一样,只要将is_admin
属性修改为'1'即可。
其它
将 SYZOJ 设置为bash快速启动.
vim [syzoj2 path]/runsyzoj
将 runsyzoj
文件改为如下代码.
#!/bin/bashcd [syzoj2 path]npm start > log.txt 2>&1
请改为自己的 [syzoj2 path]
.
将 SYZOJ 设置为系统服务
添加 /etc/systemd/system/syzoj.service
文件,加入如下内容.
[Unit]Description=SYZOJ Online JudgeAfter=network.target[Service]Type=simplePIDFile=/run/syzoj.pidWorkingDirectory=[syzoj2 path]ExecStart=[syzoj2 path]/runsyzojStandardOutput=nullStandardError=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-judege2cd 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 installcd node_modules/syspipenpm installcd ../..npn run buildcp instance-config-example.json instance-config.jsoncp shared-config-example.json shared-config.json
或者 yarn
(如果您已经安装yarn
)
设置
修改 instance-config.json
shared-config.json
一些例子:
运行 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/bashcd [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 DaemonAfter=network.target[Service]Type=simplePIDFile=/run/syzoj-judge.pidWorkingDirectory=[syzoj-judge path]ExecStart=[syzoj-judge path]/runjudgeStandardOutput=nullStandardError=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中文安装指南
- GreenSQL中文安装指南
- Piwik中文安装指南
- Liferay安装中文指南-windows
- liferay portal 中文安装指南
- SYZOJ 156 [FZU] 别踩黑块!
- CDH5.5.1 安装指南 中文首发版
- Squid中文权威指南 第三章(编译和安装)
- Liferay安装中文指南-Linux和Mac OS X
- Vmware6.0虚拟机中文绿色版[安装使用完全指南]
- LaTex 安装与中文排版环境配置指南
- Vmware6.0虚拟机中文绿色版[安装使用完全指南]
- SCOM 简单安装指南 [SCOM中文系列之二]
- FCF中文指南-第二章--FusionCharts Free安装
- FusionCharts Free中文开发指南 第二章--FusionCharts Free安装
- 红帽企业版Linux 6安装指南(中文)
- jQuery中文入门指南
- libxml2 指南(中文)
- get()与getline()
- 配置篇 06. 添加桌面图标 ❀ Windows Server 2016
- JavaScript实现-找出最长单词-Find the Longest Word in a String
- 昆石VOS3000_2.1.2.4安装脚本
- UMSocialPlatformErrorDomain Code=2001
- SYZOJ中文安装指南
- quartz和sping的集成和使用
- Unity的Gamma渲染管线和Linear管线的区别
- Nginx防盗链的3种方法
- CentOs7虚拟机与防火墙
- MFC+Opencv显示图像的几种方法
- eclipse hadoop windows 运行wordcount程序,上传文件内容为空的原因及解决办法
- [Leetcode-460]LFU Cache 最近不常用页面交换
- python3的pkl文件转换成python2的pkl文件【pickle】