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中文安装指南的更多相关文章

  1. android studio1.0 for Mac环境搭建与demo运行(手动下载gradle,科学上google) 转载

    http://blog.csdn.net/allenffl/article/details/41957907 官网下载 http://developer.android.com/sdk/install ...

  2. 如何在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 ...

  3. wazuh官方安装指南(中文译版本)

      安装Wazuh服务器 Wazuh服务器可以安装在任何类型的Unix操作系统上.最常见安装在Linux上.如果可以为您的系统提供自动化脚本,则安装过程会更容易,但是,从源码构建和安装也非常简单. 通 ...

  4. 全新 Mac 安装指南(通用篇)(推荐设置、软件安装、推荐软件)

    注:本文将会不定期维护与更新,有需要的朋友请在 Github 上订阅该条 Issues:<全新 Mac 安装指南(通用篇)>. 在 Mac 电脑上只用 Windows 操作系统的同学请看到 ...

  5. ArchLinux安装指南

    将ArchLinux作为进阶Linux发行版,主要看重滚动更新和深入理解Linux的安装过程. 由于是新手,所以先选择在公司电脑上用VMware来安装.然后渐进到借助U盘在win10笔记本上安装双系统 ...

  6. Ubuntu14.04安装中文输入法以及解决Gedit中文乱码问题

    1 设置中文显示环境 1. 打开System Settings 2. 打开Personal-> Language Support. 会弹出如下对话框,提示你“语言支持没安装完整”. 点击“Rem ...

  7. Ubuntu14.04安装中文输入法以及解决Gedit中文乱码问题[转载]

    转载自:http://www.cnblogs.com/zhcncn/p/4032321.html 写在前面:解决gedit 在txt文件格式出现乱码的问题,在我自己的操作中是需要把系统设置成中文显示环 ...

  8. OpenERP 7.0 中文报表PDF乱码(WindowsXP)

    OpenERP默认安装输出的PDF中文报表都是一些方块: 此问题可以通过oecn_base_fonts模块解决: 更多关于oecn_base_fonts的信息请参考: 1. OpenERPv7.0 中 ...

  9. Visual C++2010开发权威指南 中文高清PDF - VC.NET

    第一部分  Visual C++ 2010开发与新特性第1章  Visual C++ 2010开发环境简介 11.1  Visual C++ 2010简介 11.2  Visual C++ 2010下 ...

随机推荐

  1. DocumentFormat.OpenXml read excel file

    这里向大家介绍一种读取excel 数据的方法,用的是DoucmentFormat.OpenXml.dll 废话不多说,向大家展示一下在项目中处理过的方法,如果有任何疑问,随时联系我. using Do ...

  2. Angular 表单嵌套、动态表单

    说明: 组件使用了ng-zorro (https://ng.ant.design/docs/introduce/zh) 第一类:嵌套表单 1. 静态表单嵌套 demo.component.html & ...

  3. redis 漏洞造成服务器被入侵-CPU飙升

    前言   前几天在自己服务器上搭了redis,准备想着大展身手一番,昨天使用redis-cli命令的时候,10s后,显示进程已杀死.然后又试了几次,都是一样的结果,10s时间,进程被杀死.这个时候我还 ...

  4. 多线程基础(主要内容转载于https://segmentfault.com/a/1190000014428190)

    进程作为资源分配的基本单位 线程作为资源调度的基本单位,是程序的执行单元,执行路径(单线程:一条执行路径,多线程:多条执行路径).是程序使用CPU的最基本单位. 线程有3个基本状态: 执行.就绪.阻塞 ...

  5. ELK 学习笔记之 elasticsearch head插件安装

    elasticsearch head插件安装: 准备工作: 安装nodejs和npm https://nodejs.org/en/download/ node-v6.11.2-linux-x64.ta ...

  6. 前端之CSS基础及使用方法

    CSS介绍 CSS(Cascading Style Sheet,层叠样式表)定义如何显示HTML元素. 当浏览器读到一个样式表,它就会按照这个样式表来对文档进行格式化(渲染). CSS语法 CSS实例 ...

  7. 深入了解opacity和rgba

    1. rgba 首先它是一个属性值,语法为rgba(r,g,b,a) - r为红色值, 正整数 | 百分数 - g为绿色值,正整数 | 百分数 - b为蓝色值,正整数 | 百分数 - a为alpha( ...

  8. 原生js使用getComputedStyle方法获取CSS内部属性值

    在对网页进行调试的过程中,经常会用到js来获取元素的CSS样式, 1.下面的方法只能JS只能获取写在html标签中的写在style属性中的值(style=”…”),而无法获取定义在<style ...

  9. 【NOIP2003】传染病控制

    Description 问题背景: 近来,一种新的传染病肆虐全球.蓬莱国也发现了零星感染者,为防止该病在蓬莱国大范围流行,该国政府 决定不惜一切代价控制传染病的蔓延.不幸的是,由于人们尚未完全认识这种 ...

  10. restTemplate getForObject中map传参问题

    在使用restTemplate中getForObject的map传参形式时: 开始时我是这么调用的: RestTemplate rest = new RestTemplate(); Map<St ...