前提
本次实验的环境如下:
Ubuntu18.04.5
原本安装ubuntu使用的是版本是18.10但是出现各种各样的问题,最后改用18.04.5版本
1.首先搭建安装Ubuntu环境
ubuntu下载:https://ubuntu.com/download/desktop
或 https://developer.aliyun.com/mirror/?spm=5176.13910061.1173276.2.54d27c6dDf8kgG
可参考此教程:https://blog.csdn.net/qq_31939617/article/details/100114546
2.在安装CTFd需要先更换源
编辑源文件:
sudo gedit /etc/apt/sources.list
把里面的内容全部替换下面的源:
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src 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-backports main restricted universe multiverse
也可以参考此链接下面的别的源
https://developer.aliyun.com/mirror/ubuntu?spm=a2c6h.13651102.0.0.29911b118PBFmm
或者百度搜索ubuntu更换国内源
更换过后保存,如无法保存使用命令
sudo chmod 777 /etc/apt/sources.list
使文件可编辑
3.更新源(重中之重)
sudo apt-get upgrade
4.安装git
sudo apt install git
5.安装pip
先查看python版本,直接在终端窗口输入python查看,使用exit()推出
使用命令安装pip
sudo apt install python3-pip(我的python环境使python3)
如是安装时出现错误:Traceback (most recent call last): 或者time out 需要更换pip镜像源
5.1更换pip镜像源
若首次更换,则创建pip.conf文件:
mkdir ~/.pip
cd ~/.pip
touch pip.conf
编辑pip.conf文件:
sudo gedit ~/.pip/pip.conf
打开pip.conf文件窗口,将以下内容复制到文件中:
[global]
index-url = http://pypi.douban.com/simple
[install]
trusted-host=pypi.douban.com
6.安装Flask或flask
sudo pip install Flask 或 sudo pip install flask(使用的是Flask中的flask实验安装的是flask)
ps:
7.克隆CTFd
sudo git clone https://github.com/CTFd/CTFd.git
8.安装CTFd
cd CTFd
sudo pip3 install -r requirements.txt
sudo python3 ./serve.py
然后浏览器输入 127.0.0.1:4000 查看
9.安装gunicorn让CTFd可以用ip访问
cd CTFd
sudo pip3 install gunicorn
gunicorn --bind 0.0.0.0:8000 -w 20 "CTFd.create_app()"
然后查看ubuntu的IP地址
ifconfig -a
显示
Command 'ifconfig' not found, but can be installed with:
sudo apt install net-tools
使用命令安装
sudo apt install net-tools
再次使用
ifconfig -a
查看
输入 本机ip:8000
10.安装参考
视频安装可以看这两位师傅的: