Talking about the new version of CTFd installation and later operation and maintenance

Verbatim large column  https://www.dazhuanlan.com/2019/08/27/5d646e937bce9/

Some time ago the school community organized a CTF small game, when the CTFd is to use this platform. Frustratingly CTFd recently updated, so the old version of the package I have not installed on. Recent studies a bit new version of CTFd (v2.1.2), incidentally also finished a new version of CTFd. Overall, the current CTFd more powerful, and became the team competition and individual competition in two modes, you can also operate rewards points, and so to some users in the background ... administrators
official Github Address

Environmental requirements

Installation process

I feel Docker installation easier, and therefore the installation of a docker-compose up way.

First install Docker

Installation package needed

1
sudo yum install -y yum-utils device-mapper-persistent-data lvm2 bind-utils

Set yum source

1
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

Installation docker

1
sudo yum install docker-ce

Start and join the boot

1
2
sudo systemctl start docker
sudo systemctl enable docker

Verify that the installation was successful

1
docker version

Installation docker-compose

Reference link
to install python-pip

1
2
yum -y install epel-release 
yum -y install python-pip

Pip check whether the installation was successful

1
pip -V


To pip install upgrade (optional)

1
pip install --upgrade pip

Officially begin the installation docker-compose

1
pip install docker-compose

Installation pip error and workarounds

1
2
If the error: ReadTimeoutError: HTTPSConnectionPool (host = ' pypi.python.org', port = 443): Read timed out 
Solution: pip --default-timeout = 200 install -U docker-compose

Check the docker-compose is successfully installed

1
docker-compose -version

Download CTFd

If you do not install the git git on your system

1
sudo yum install -y git

From the clones CTFd Github

1
git clone https://github.com/ctfd/ctfd.git

You can also download my good package archive upload it directly to your server, v2.1.2 version, current date.
Download link address, password: xg7e
download after successful decompression, you can see a CTFd document folder
home directory structure of CTFd


thereafter you can choose whether to use the Chinese version, if you want to use the Chinese version, download the finished package offered to replace my home directory themes directory under / CTFd path to (remember to do a backup).
Finished package download link address, password: nkqd
then under the home directory CTFd

1
docker-compose up

Quietly wait for the installation to complete successfully will pop up http://0.0.0.0:8000

at this time, your CTFd installation is complete.

If you can not access the installation is successful, look at the port is not a firewall to filter out.

Speaking effect

替换themes目录后效果如下:

后续运维

CTFd的数据库用的是mariadb,看一下docker运行了哪些容器

可以看到运行了三个容器,分别是ctfd,mariadb,redis
我们可以直接进入到各个容器进行操作。

1
docker exec -it [CONTAINER ID] /bin/bash

数据库root账户的密码默认为ctfd

原先旧版的CTFd如果数据库不设置UTF-8会乱码,新版本测试过程中没碰到此类问题,如果乱码就进入到ctfd数据库敲一下命令

1
ALTER TABLE [table name] CONVERT TO CHARACTER SET utf8;

配置Nginx

如果有需要的话也可以配置一下nginx,这样访问速度会变快,而且作为一个中间件更改端口会更方便(当然小伙伴们选择Apache也是可以的)。
参考链接

安装所需环境

1
2
3
4
yum install gcc-c++
yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
yum install -y openssl openssl-devel

根目录下新建一个文档夹nginx

1
2
3
4
mkdir /nginx
cd /nginx
wget https://nginx.org/download/nginx-1.14.2.tar.gz
tar -zxvf nginx-1.14.2.tar.gz

然后进入到目录下进行编译

1
2
3
./configure
make
make install

查找一下nginx的位置
whereis nginx

nginx常见命令

启动、停止nginx

1
2
3
4
5
6
7
cd /usr/local/nginx/sbin/
./nginx
./nginx -s stop
./nginx -s quit
./nginx -s reload
./nginx -s quit:此方式停止步骤是待nginx进程处理任务完毕进行停止。
./nginx -s stop:此方式相当于先查出nginx进程id再使用kill命令强制杀掉进程。

nginx开机自启动

即在rc.local增加启动代码就可以了。
vi /etc/rc.local
增加一行 /usr/local/nginx/sbin/nginx (根据whereis nginx实际的位置为准)
设置执行权限:
chmod 755 rc.local
配置nginx
配置之前需要先运行一下nginx

1
2
./nginx
./nginx -s quit

然后在修改配置文档
vim /usr/local/nginx/conf/nginx.conf(whereis nginx 实际情况)
server下的location替换为

1
2
3
4
5
6
7
location /{
proxy_pass http://localhost:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect off;
}


Finally, the need to open firewall port 80
firewall-cmd --zone=public --add-port=80/tcp --permanent
and then start clicking nginx can access your CTFd 80 through the port.


Note: Some installation steps from the Internet, have marked the original link.

Guess you like

Origin www.cnblogs.com/petewell/p/11417866.html