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. 配置eclipse编写html/js/css/jsp/java时自动提示

    配置eclipse编写html/js/css/jsp/java时自动提示步骤: 1.打开eclipse→Windows→Preferences→Java→Editor→Content Assist 修 ...

  2. Proxy实现java动态代理

    在java设计模式中代理模式的应用比较广泛, 比如我在编写一写web程序时在filter修改request或response时, 而request中并没有相应的set方法, 这样要做到修改就需要使用一 ...

  3. shell 获取当前目录下的jar文件

    1.示例 function getDir() { ` do fileName=$"/"$item if [ -d $fileName ] then echo $fileName&q ...

  4. grep、正则表达式

    1.grep :文本搜索工具 -i:忽略大小写--color:匹配到的内容高亮显示-v:显示没有被模式匹配到的行-o:只显示被模式匹配到的字符串-n:显示匹配到行的行号-E:使用扩展正则表达式-A:后 ...

  5. 〈四〉ElasticSearch的认识:基础原理的补充

    目录 想想我们漏了什么 回顾 补回 集群的建立 集群发现机制 配置文件 健康状态 补充: 小节总结 分片的管理 梳理 分片的均衡分配 主副分片的排斥 容错性: 数据路由 对于集群健康状态的影响 小节总 ...

  6. 从 axios 源码中了解到的 Promise 链与请求的取消

    axios 中一个请求取消的示例: axios 取消请求的示例代码 import React, { useState, useEffect } from "react"; impo ...

  7. 快学Scala 第十四课 (读取行,读取字符, 控制台读取)

    读取行: import scala.io.Source object FileReader { def main(args: Array[String]): Unit = { val source = ...

  8. linux无法安装应用

    需安装flex 和bison 一般需要更新软件源 root权限 下 apt-get update apt-get upgrade 如果出现以下问题,先查看网络是否畅通: ping 192.168.0. ...

  9. Nginx的基本安装配置

    Centos7安装nginx 升级nginx 升级可能遇到问题(我没有遇到, 参考的另一篇文章描述的) 检查nginx版本, 确认安装成功 nginx配置文件 虚拟主机配置 配置文件中可以用的全局变量 ...

  10. 使用LitePal升级表

    传统的升级表方式   上一篇文章中我们借助MySQLiteHelper已经创建好了news这张表,这也是demo.db这个数据库的第一个版本.然而,现在需求发生了变更,我们的软件除了能看新闻之外,还应 ...