• SYZOJ中文安装指南


    欢迎移步我的网站

    Made By:Spaceskynet
    Thanks to other developers.

    测试系统 Ubuntu-17.04

    Ubuntu

    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

  • 相关阅读:
    C语言编程题
    boost-使用说明
    CButton控件
    sprintf()与sscanf()
    MFC中的几个虚函数
    CProgressCtrl进度条控件实现进度滚动效果
    移动窗口和根据条件查找指定窗口
    VC播放mp3的方法
    CEdit控件[转]
    关于鼠标的一些操作
  • 原文地址:https://www.cnblogs.com/spaceskynet/p/7411457.html
Copyright © 2020-2023  润新知