1. 程式人生 > >syzoj 中文安裝指南 docker簡易版

syzoj 中文安裝指南 docker簡易版

put 限制 5.4 lse blank 數據庫 input localhost .json

今天,由likecoding的博主給大家帶來如何安裝syzoj

準備工具:

一臺ubuntu18.04的電腦

本文GitHub地址:https://github.com/jyeric/hexo3

本文第二鏈接(自己的hexo博客鏈接):https://jyeric.likecoding.gq

更新將在第二鏈接及github進行更新csdn請關註評論內容

預備依賴項:

1
2
sudo apt-get update && sudo apt-get install -y vim git
sudo apt-get install docker-compose

第一步 git clone (註:git內容不是我寫的,出現問題請加入loj群詢問)

1
git clone https://github.com/hewenyang/syzoj-docker

第二步 sandbox

1
2
3
4
cd ..   (回到根目錄中)
cd home
mkdir hewenyang
cd hewenyang

下載sandbox (註:sandbox不是我寫的,安全性未知,內容請詢問t123yh)

1
https://seafile.t123yh.xyz:2/f/65f061a56f414b3db478/

服務器請先下載,使用filezilla進行上傳

第三部 修改文件

1
cd ..

(返回根目錄)

1
vi /etc/default/grub

找到 GRUB_CMDLINE_LINUX_DEFAULT 一行,在引號內加入 swapaccount=1

如果在這一行中有其他內容請在引號內先空格,再加入上述內容

備註:配置文件

daemon.json 默認,不建議更改

位置:syzoj-docker/config/daemon.json

1
2
3
4
5
6
7
8
{
"RabbitMQUrl": "amqp://localhost/",
"RedisUrl": "redis://127.0.0.1:6379",
"TestData": "/mnt/syzoj-data/uploads/testdata",

"Priority": 1,
"DataDisplayLimit": 100,
"TempDirectory": "/tmp"
}

runner-shared.json默認,不建議更改
位置:syzoj-docker/config/runner-shared.json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
{
"RabbitMQUrl": "amqp://localhost/",
"RedisUrl": "redis://127.0.0.1:6379",
"TestData": "/mnt/syzoj-data/uploads/testdata",
"Priority": 1,
"DebugMessageDisplayLimit": 5000,
"OutputLimit": 104857600,
"StderrDisplayLimit": 5120,
"DataDisplayLimit": 128,
"CompilerMessageLimit": 50000,
"SpjTimeLimit": 1501,
"SpjMemoryLimit": 256,
"SandboxEnvironments": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"HOME=/tmp"
],
"SandboxUser": "nobody",
"SandboxRoot": "/sandbox-rootfs",
"BinaryDirectory": "/mnt/syzoj-bin"
}

web.json可以更改,更改請見下面說明
位置:syzoj-docker/config/web.json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
{
"title": "SYZOJ", // 網站名,可以改!
"hostname": "0.0.0.0", // 不要改!
"db": {
"database": "syzoj", //若使用外部mysql數據庫,請進行更改
"username": "syzoj",
"password": "syzoj",
"host": "mysql",
"dialect": "mysql"
},
"register_mail": false, // 見 https://github.com/syzoj/syzoj#郵件配置
"email": {
"method": "aliyundm",
"options": {
"AccessKeyId": "xxxx",
"AccessKeySecret": "xxxx",
"AccountName": "xxxx"
}
},
"upload_dir": "uploads", // 評測數據上傳目錄
"default": { // 默認配置
"problem": {
"time_limit": 1000, // 時間限制
"memory_limit": 256 // 內存限制
},
"user": {
"show": true,
"rating": 1500
}
},
"sorting": {
"ranklist": {
"field": "rating",
"order": "desc"
},
"problem": {
"field": "id",
"order": "asc"
}
},
"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", // session
"judge_server_addr": "http://127.0.0.1:5284", // 評測機地址
"judge_token": "233", // 評測機 Token
"email_jwt_secret": "test" // email jsonwebtoken secret
}

docker-compose.yml:
位置:syzoj-docker/docker-compose.yml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
version: ‘2.3‘
services:
web:
build: .
ports:
- "5283:5283" //5283:5283前面的是暴露的端口可以改成80(80:5283,後面的不要改動
tmpfs:
- /mnt/syzoj-tmp1
- /mnt/syzoj-tmp2
- /mnt/syzoj-bin
volumes:
- /home/hewenyang/syzoj-docker/sandbox-rootfs:/sandbox-rootfs
- /opt/syzoj/data:/mnt/syzoj-data
privileged: true
networks:
syzoj_net:
ipv4_address: 172.16.0.2
ipv6_address: fc00::10
depends_on:
- mysql

stdin_open: true
tty: true
mysql:
image: "mysql:5.6"
networks:
syzoj_net:
ipv4_address: 172.16.0.3
ipv6_address: fc00::11
environment:
MYSQL_ROOT_PASSWORD: "root"

networks:
syzoj_net:
driver: bridge
enable_ipv6: true
ipam:
driver: default
config:
- subnet: 172.16.0.0/24
- subnet: fc00::/64

第四部 安裝

回到剛才git clone的目錄

運行 docker-compose up -d,隨後便可以通過 127.0.0.1:5283 (或您指定的端口)訪問。根據網絡情況,構建過程可能會花費幾分鐘至幾小時不等,也可能由於失敗而中斷,重新執行該指令即可,直到最終顯示出 mysql 和 web 等字樣。

打開你的ip:5283就可以訪問了,註冊一個號,即可使用。

第五步 安裝後的操作

可以通過 docker exec -it build_web_1 /bin/bash 來訪問容器的 shell。

隨後執行 mysql -hmysql -uroot -proot 可以訪問 MySQL 服務器,執行賦予管理員權限等操作。

在user中的is_admin體現了是不是管理員

然後就可以放題目了!

參考資料

1.官方syzoj:https://github.com/syzoj/syzoj

2.syzoj-docker:https://github.com/hewenyang/syzoj-docker

3.billchenchina的博客:https://billchen.bid/jekyll/update/2018/05/13/SYZOJ-Install-Guide/

更新日期:20180822

syzoj 中文安裝指南 docker簡易版