Centos7下DVWA搭建简单记录
1、更新yum
sudo yum update
这里可能需要等待比较长的时间。
2、安装apache
$ sudo yum install httpd #安装
$ sudo systemctl enable httpd.service #设置自启动
$ sudo systemctl is-enabled httpd.service #判断重启后是否启动
$ sudo systemctl start httpd.service #启动apache
$ sudo systemctl stop httpd.service #关闭Apache
# Apache默认将网站的根目录指向/var/www/html
# 默认的主配置文件/etc/httpd/conf/httpd.conf
# 配置存储在的/etc/httpd/conf.d/目录
3、安装php
$ sudo yum install php php-mysql #安装软件序列
$ sudo systemctl restart httpd.service #重启apache服务
4、安装mariadb
$ sudo yum install mariadb-server #安装
$ sudo systemctl enable mariadb #启动服务
$ sudo systemctl start mariadb
$ sudo mysql_secure_installation #这里配置root密码
5、创建dvwa库
[root@localhost conf.d]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 13
Server version: 5.5.68-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
MariaDB [(none)]> create database dvwa;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all on dvwa.* to dvwa@localhost identified by 'dvwa账号的密码';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> exit
Bye
[root@localhost conf.d]#
[root@localhost conf.d]# systemctl restart mariadb
6、安装dvwa
$ wget https://github.com/ethicalhack3r/DVWA/archive/master.zip #下载压缩包
$ unzip master.zip #解压
$ mv DVWA-master /var/www/html/ #剪切压缩包
$ cd /var/www/html/
$ mv DVWA-master DVWA #重命名
$ cd ./DVWA/config/ #进入config目录
$ cp config.inc.php.dist config.inc.php
$ vim config.inc.php
#编辑,其中
$_DVWA[ 'db_server' ] = '127.0.0.1';
$_DVWA[ 'db_database' ] = 'dvwa';
$_DVWA[ 'db_user' ] = 'dvwa';
$_DVWA[ 'db_password' ] = 'dvwa账号的密码';
$_DVWA[ 'db_port'] = '3306';
# ReCAPTCHA settings
# Used for the 'Insecure CAPTCHA' module
# You'll need to generate your own keys at: https://www.google.com/recaptcha/admin
$_DVWA[ 'recaptcha_public_key' ] = '设置你的key';
$_DVWA[ 'recaptcha_private_key' ] = '设置你的key';
#修改php配置文件
$ vim /etc/php.ini #vi /etc/php.ini
#编辑,将allow_url_include = Off的参数改为 on
$ sudo systemctl restart httpd.service #重启 Apache
7、访问dvwa
访问 http://your ip /DVWA
8、如果出现Forbidden
Forbidden
You don't have permission to access /DVWA/setup.php on this server.
$ setenforce 0 # 关闭selinux,再访问就正常了