CTFd平台的搭建(基于ubuntu20.04)

该文介绍了如何在Ubuntu20.04上进行系统配置,包括启用root账号、修改root密码、配置网络、更换镜像源等。然后详细讲解了CTFd平台的搭建步骤,包括安装依赖、下载CTFd源码、修改配置文件及启动服务。文中还提到了针对网络问题的解决办法和使用gunicorn进行服务优化。
摘要由CSDN通过智能技术生成

【准备工作】

在虚拟机默认安装ubuntu20.04,配置网络

启用root账号,以root账号登录

cd /usr/share/lightdm/lightdm.conf.d/

vim 50-unity-greeter.conf  //如果没有vim 可以执行命令 sudo apt install vim安装

输入以下内容:

user-session=ubuntu
greeter-show-manual-login=true
all-guest=false

保存退出

sudo passwd root  //修改root密码,修改后可以用su root测试是否修改密码成功

sudo vim /etc/pam.d/gdm-autologin

前面加 # 注释掉第三行的 auth required pam_succeed_if.so user != root quiet_success

sudo vim /etc/pam.d/gdm-password 

前面加 # 注释掉第三行的 auth required pam_succeed_if.so user != root quiet_success

sudo vim /root/.profile

将文件末尾的 mesg n 2> /dev/null || true 这一行修改成
tty -s&&mesg n || true

重启系统

更换更优下载源:

备份/etc/apt/sources.list
#备份
cp /etc/apt/sources.list /etc/apt/sources.list.bak

在/etc/apt/sources.list文件前面添加如下条目
#添加阿里源
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

最后执行如下命令更新源
##更新
sudo apt-get update
sudo apt-get upgrade

另外其他几个国内源如下: 
中科大源
##中科大源
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

163源
##163源
deb http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse

清华源
##清华源
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

【开始搭建】

sudo apt-get update

sudo apt-get upgrade

以上两句在后面的安装编译过程中经常要执行一下,如果搭建过程中遇到”出现 dpkg 被中断,您必须手工运行 sudo dpkg --configure -a“的问题,可以执行下命令:sudo rm /var/lib/dpkg/updates/*

执行命令:

sudo apt install git

sudo apt install python3-pip

sudo pip3 install Flask

建议此处执行下上面两句更新命令

sudo git clone https://github.com/isislab/CTFd.git  //下载ctfd

  • 有时候github被墙,下载会失败。可以在需要克隆的项目的.com后加入.cnpmjs.org,可以实现下载加速。此方法未测试,偶然在搜索时看到这个说法,记录下备用
  • 例如:https://github.com/easzlab/kubeasz.git
    https://github.com.cnpmjs.org/easzlab/kubeasz.git

cd CTFd  //进入下载后的ctfd目录

vim ./prepare.sh

因为ubuntu20.04自带python3,所以须修改python-dev为python3-dev,python-pip为 python3-pip,pip install -r requirements.txt 为 pip3 install -r requirements.txt 

sudo ./prepare.sh

sudo python3 serve.py

执行完毕后,通过http://127.0.0.1:4000 已可访问平台。不过如果希望其他电脑可以访问,还需安装gunicorn或类似的软件

建议此处执行下上面两句更新命令

cd CTFd

pip3 install gunicorn

sodu gunicorn --bind 0.0.0.0:8000 -w 4 "CTFd:create_app()"  //这个命令一定要在ctfd目录下执行

此时在其他电脑通过http://ip:8000 可以访问平台。不过会比较慢,建议安装nginx

sudo apt install nginx

cd /etc/nginx/conf.d

 

 

分类: Ubuntu系列

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值