搭建Lamp请看:https://blog.csdn.net/qq_41709494/article/details/89430834
1.下载DVWA地址:http://www.dvwa.co.uk/
2. 安装Lamp的所有包
[root@localhost ~]# yum install php php-mysql php-gd httpd mariadb mariadb-server -y
3.解压DVWA压缩包
[root@localhost ~]#yum install unzip -y #安装unzip解压软件
[root@localhost ~]#unzip DVWA-master_\(1\).zip #解压压缩包
[root@localhost ~]# ls DVWA-master
about.php COPYING.txt external ids_log.php login.php php.ini security.php
CHANGELOG.md docs favicon.ico index.php logout.php README.md setup.php
config dvwa hackable instructions.php phpinfo.php robots.txt vulnerabilities
4.启动和设置自动开机服务
[root@localhost ~]# systemctl start mariadb #开启mariadb
[root@localhost ~]# systemctl start httpd #开启httpd
[root@localhost ~]# systemctl enable mariadb #设置开机自动开启mariadb
[root@localhost ~]# systemctl enable httpd #设置开机自动开启httpd
5.设置数据库密码和查看数据库
[root@localhost ~]# mysqladmin -u root password '123456' #设置Mariadb密码为123456
[root@localhost ~]# mysql -u root -p123456
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 5.5.56-MariaDB MariaDB Server
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)
MariaDB [(none)]> exit
Bye
[root@localhost ~]#
6. 移动到apache根目录下和改所有权
[root@localhost ~]# mv DVWA-master /var/www/html #把解压好的文件移动到apache根目录下
[root@localhost ~]# chown -R apache:apache /var/www/html/* #更改所属用户和所属用户组
[root@localhost ~]# cd /var/www/html/ #切换到apache根目录
[root@localhost html]# ll
总用量 4
drwxr-xr-x. 8 apache apache 4096 2月 6 16:11 DVWA-master
7.查看DVWA的配置文档,配置DVWA
[root@localhost ~]# cd /var/www/html/DVWA-master/config #切换到配置文档
[root@localhost config]# ls
config.inc.php.dist
[root@localhost config]# cat config.inc.php.dist
[root@localhost config]# vi config.inc.php.dist
...
$_DVWA = array();
$_DVWA[ 'db_server' ] = '127.0.0.1';
$_DVWA[ 'db_database' ] = 'dvwa';
$_DVWA[ 'db_user' ] = 'root';
$_DVWA[ 'db_password' ] = '123456'; #修改正确数据库的密码
...
7.浏览网页,但是出现错误
[root@localhost config]# cp config.inc.php.dist config.inc.php
[root@localhost config]# ll
总用量 8
-rw-r--r--. 1 root root 1855 6月 5 22:35 config.inc.php
-rw-r--r--. 1 apache apache 1855 6月 5 22:30 config.inc.php.dist
[root@localhost ~]# chown -R apache:apache /var/www/html/* #更改所属用户和所属用户组
7-1.解决方法
[root@localhost DVWA-master]# more php.ini #查看DVWA的php怎么配置
; This file attempts to overwrite the original php.ini file. Doesnt always work.
magic_quotes_gpc = Off
allow_url_fopen on
allow_url_include on
[root@localhost DVWA-master]# cd #切换到/root
[root@localhost ~]# vi /etc/php.ini #编辑php配置
...
allow_url_include = Off 改为 On
...
[root@localhost ~]# systemctl restart httpd
#还有错误,验证码的问题
7-2.解决方法
[root@localhost DVWA-master]# cd config/
[root@localhost config]# vi config.inc.php #编辑验证码
...
# 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' ] = '';
$_DVWA[ 'recaptcha_private_key' ] = '';
...
申请公钥和私钥recaptcha验证码,需要才能浏览:https://www.google.com/recaptcha/admin
recaptcha验证码的生成,此处就省略
8.自动创建DVWA的数据库
[root@localhost config]# mysql -u root -p123456
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 34
Server version: 5.5.56-MariaDB MariaDB Server
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| dvwa |
| mysql |
| performance_schema |
| test |
+--------------------+
5 rows in set (0.00 sec)
9.登录DVWA,默认用户是admin,密码是password
10.进入后台,就搭建成功了