ARTICLE

DVWA Installation in Windows

By Skills Uprise · 25 Jul 2026

SKILLS UPRISE · CYBER LAB SERIES · LAB 02B

Install DVWA on Windows with XAMPP

The Damn Vulnerable Web Application — a PHP app built to be broken, so you can practise SQL injection, XSS, command injection and file upload attacks on something you are actually allowed to attack. Twelve steps. Two of them exist because the version of this guide going round in slide decks gets the database configuration wrong in a way that will bite you.


Beginner · 20–30 minutes · Requires Lab 02A · Windows 10 or 11 · Updated July 2026

BUILD SHEET


ini
app          DVWA (github.com/digininja/DVWA)
runs on      XAMPP from Lab 02A
extract to   C:\xampp\htdocs\dvwa
url          http://localhost/dvwa/setup.php
db name      dvwa
db user      dvwa        # NOT root
db host      127.0.0.1
db port      3306
app login    admin / password  -> change it
bind         127.0.0.1 only, always
when idle    stop Apache and MySQL

A dedicated database user, not root. DVWA's own config file says so, and XAMPP ships MariaDB — see the corrections below.

⚠️

Read this before you install it

DVWA is not insecure by accident. Every module in it is a working vulnerability, deliberately left in, with the protections removed. That is exactly what makes it a good teacher and exactly why where you put it matters more than how you install it. Three rules, and they are not negotiable in this course: 1. It stays on 127.0.0.1. If you completed Part 4 of Lab 02A, Apache is already bound to localhost only. Verify it again in step 11. DVWA reachable from your hostel or campus wifi is a working SQL injection endpoint that anyone on that network can find, and the machine it leads to is yours. 2. It never goes on a hosting account, a VPS, or any server with a public address. DVWA's own documentation is blunt about this. “It is only local, nobody knows the URL” is not a control — scanners find paths like /dvwa within hours of a host appearing. 3. Attack only your own copy. The skills transfer to any web application; the permission does not. Practising on someone else's site is an offence under the Information Technology Act in India, whatever you learned it on. If your Windows machine is also your everyday laptop, the safer arrangement is to run XAMPP and DVWA inside the VM you built in Lab 01 and reach it from Kali over a host-only network. Lab 04 sets that up properly.

BEFORE YOU FOLLOW AN OLDER GUIDE

Three things most DVWA walkthroughs get wrong

Search for a DVWA install guide and most of them tell you to point it at the database as root with a blank password. That advice predates XAMPP shipping MariaDB, and DVWA's own configuration file now warns against it in a comment you can read in the screenshot at step 6. Here is what to do instead, and why.

CORRECTION 1

Not root — a dedicated dvwa user

DVWA's config file states that on MariaDB you cannot use root and must create a dedicated user. XAMPP ships MariaDB, not MySQL, so that applies to you. Step 5 creates the user with privileges on one database only — which is also how you would provision a real application.

CORRECTION 2

db_database is 'dvwa', not 'root'

Some decks show db_database set to root. That field is the database NAME, and the config file warns that whatever you name there will be entirely deleted during setup. Naming it root creates a database called root and teaches a wrong mental model. It should read dvwa.

CORRECTION 3

Do not blank the password

“Set the password to blank” only works if your database has no root password — which means undoing the hardening from Lab 02A. With a dedicated user carrying its own password, the database stays protected and DVWA still connects. You lose nothing.

PART 1 OF 4

Get DVWA into htdocs

Three steps. The only decision is what you name the folder.


IF YOU SKIPPED LAB 02A

You need XAMPP first

DVWA is not a program you run — it is PHP source code that needs a web server, PHP and a database to run inside. That is what XAMPP provides. Install it from apachefriends.org, not from a download portal, and work through the hardening in Part 4 of Lab 02A before you come back here.

The XAMPP download for Windows. Take it from apachefriends.org — the official site — rather than a mirror

The XAMPP download for Windows. Take it from apachefriends.org — the official site — rather than a mirror.

01


STACK UP

Start Apache and MySQL, and confirm they are green

Open the XAMPP Control Panel and start Apache, then MySQL. Both module names turn green, both get a PID, and the Port column fills in — 80 and 443 for Apache, 3306 for MySQL. If either goes red, stop here and fix it before touching DVWA. The log panel at the bottom of the Control Panel names the port and the conflict, and the troubleshooting section of Lab 02A lists the usual culprits. Installing an application on top of a stack that will not start just gives you two problems to debug at once.

Apache and MySQL running: green labels, PIDs assigned, ports 80/443 and 3306 shown. This is what the Control Panel should look like before you continue

Apache and MySQL running: green labels, PIDs assigned, ports 80/443 and 3306 shown. This is what the Control Panel should look like before you continue.

02


DOWNLOAD

Clone or download DVWA from GitHub

DVWA lives at github.com/digininja/DVWA and that is the only place to get it. A deliberately vulnerable application redistributed by a random site is an unusually convenient way for someone to hand you something worse than what you asked for. Either download the ZIP from the green Code button, or clone it if you have git installed — cloning makes it trivial to pull updates later:

bash
cd C:\xampp\htdocs
git clone https://github.com/digininja/DVWA.git dvwa

While you are on that page, open the README. It states which PHP versions the current release supports — worth a glance against the PHP version your XAMPP build shipped with, because that mismatch is the cause of most “some modules just error” reports.

The DVWA repository at github.com/digininja/DVWA. The Code button gives you the ZIP; the config folder is where step 3 takes you

The DVWA repository at github.com/digininja/DVWA. The Code button gives you the ZIP; the config folder is where step 3 takes you.

03


EXTRACT

Extract to C:\xampp\htdocs\dvwa — and rename the folder

Extract the archive into C:\xampp\htdocs. The ZIP unpacks as DVWA-master, which would make your lab live at http://localhost/DVWA-master/ — workable, but every instruction you read afterwards assumes /dvwa/. Rename the folder to lowercase dvwa. Do not extract it into htdocs root. Some older guides do, which puts DVWA's setup.php at http://localhost/setup.php and mixes its files in with everything else you will host. Keep it in its own folder:

text
C:\xampp\htdocs\
  dashboard\          <- XAMPP's own pages
  lab.php             <- your file from Lab 02A
  dvwa\               <- DVWA lives here
    config\
    dvwa\
    hackable\
    setup.php
    login.php

PART 2 OF 4

Configure the database connection

Three steps, and this is where the older guides go wrong.


04


RENAME

config.inc.php.dist → config.inc.php

Go to C:\xampp\htdocs\dvwa\config. There is one file: config.inc.php.dist. Copy it — do not just rename it — to config.inc.php in the same folder. Why copy rather than rename: the .dist file is the shipped template, tracked in git. Keeping it means you can always diff your config against the original, and a git pull will not conflict with your edits. If Windows shows the file as config.inc rather than config.inc.php.dist, file extensions are hidden. Turn on File name extensions in Explorer's View tab before you rename anything — otherwise you will produce config.inc.php.php and spend twenty minutes wondering why nothing works.

The config folder before renaming: only config.inc.php.dist is present. Copy it to config.inc.php alongside it

The config folder before renaming: only config.inc.php.dist is present. Copy it to config.inc.php alongside it.

05


DB USER

Create a dedicated database user — not root

This step is missing from most walkthroughs and it is the one DVWA's own config file asks for. Open the Shell from the XAMPP Control Panel and log in with the root password you set in Lab 02A:

sql
mysql -u root -p

-- inside the MySQL prompt:
CREATE DATABASE dvwa;
CREATE USER 'dvwa'@'127.0.0.1' IDENTIFIED BY 'choose-a-strong-password';
GRANT ALL PRIVILEGES ON dvwa.* TO 'dvwa'@'127.0.0.1';
FLUSH PRIVILEGES;
EXIT;

Read what you just typed, because it is a lesson rather than a formality. GRANT ALL PRIVILEGES ON dvwa.* gives this account complete control of one database and no access to any other. If DVWA is later compromised through one of its own vulnerabilities — which is the entire point of DVWA — the attacker inherits exactly those privileges and nothing more. Hand it root instead and a successful SQL injection in a practice app owns every database on your machine. This is least privilege, and you have just implemented it. It is also the exact reasoning you will write into a client report one day.

06


EDIT CONFIG

Point config.inc.php at that user

Open C:\xampp\htdocs\dvwa\config\config.inc.php in a real editor — VS Code or Notepad++, not Notepad, which will not show you the line endings and can save with the wrong encoding. Set the database block to this:

php
$_DVWA = array();
$_DVWA[ 'db_server' ]   = '127.0.0.1';
$_DVWA[ 'db_database' ] = 'dvwa';
$_DVWA[ 'db_user' ]     = 'dvwa';
$_DVWA[ 'db_password' ] = 'choose-a-strong-password';
$_DVWA[ 'db_port' ]     = '3306';

Use 127.0.0.1 rather than localhost for db_server. On Windows, localhost can resolve to the IPv6 address ::1 while MariaDB listens only on IPv4, which produces a connection failure that looks exactly like a wrong password. Read the comments around this block in your own file as you edit. Two of them matter: the warning that the database named in db_database will be entirely deleted during setup, and the note that MariaDB users must create a dedicated account rather than using root. That second comment is the source for step 5 — it is DVWA's own instruction, not our preference.

config.inc.php open for editing. Note the two comments above the database block: the deletion warning on db_database, and the MariaDB instruction to create a dedicated user instead of using root. Set db_database and db_user to dvwa and supply the password from step 5

config.inc.php open for editing. Note the two comments above the database block: the deletion warning on db_database, and the MariaDB instruction to create a dedicated user instead of using root. Set db_database and db_user to dvwa and supply the password from step 5.

PART 3 OF 4

Create the database and log in

Two steps, and DVWA checks its own prerequisites for you.


07


SETUP

Open setup.php and press Create / Reset Database

Go to http://localhost/dvwa/setup.php. DVWA shows a status page listing everything it needs, which is genuinely useful — read it before you click anything. Green means satisfied, red means a module will misbehave. You are looking for: • Backend database: MySQL/MariaDB • Database username, database name and host matching what you set in step 6 • Writable folder …\hackable\uploads\: Yes — needed by the file upload module • Writable folder …\config: Yes • reCAPTCHA key: expect Missing unless you add your own keys, which only affects the Insecure CAPTCHA module • allow_url_fopen and allow_url_include: only needed for the File Inclusion modules, and step 9 covers them Then press Create / Reset Database at the bottom. DVWA drops and recreates its tables and seeds the practice data. The page reloads and redirects you to the login screen. That same button is how you recover later: when you have mangled the database experimenting, come back here and reset it rather than reinstalling.

The setup.php status page. Check the database values against your config and confirm both writable folders say Yes, then press Create / Reset Database

The setup.php status page. Check the database values against your config and confirm both writable folders say Yes, then press Create / Reset Database.

08


LOG IN

admin / password — then change it

DVWA's default credentials are admin and password. Log in and you land on the main page with the vulnerability modules down the left side. Change that password immediately, from the application's own UI. Yes, it is a lab. Yes, it is on localhost. Do it anyway — because the habit of leaving documented default credentials on a running service is precisely the habit that shows up as a finding on real assessments, and the way you avoid it in production is by never practising it. Then set the security level. DVWA Security in the left menu switches between Low, Medium, High and Impossible. Low is where you start; Impossible is the correctly written version of each module and is genuinely worth reading afterwards, because it shows you the fix rather than just the flaw.

PART 4 OF 4

Module prerequisites, isolation, and a rollback point

Four steps that decide whether this stays a lab.


09


FILE INCLUSION

Only if you need it: allow_url_fopen and allow_url_include

The File Inclusion modules need two PHP settings that are off by default. If setup.php showed them in red and you want to work through those exercises, edit C:\xampp\php\php.ini:

ini
allow_url_fopen = On
allow_url_include = On

Restart Apache from the Control Panel afterwards. Understand what you just enabled. allow_url_include lets PHP include and execute code from a remote URL — it is the setting that turns a local file inclusion bug into remote code execution. It has been off by default for years for exactly that reason, and it is deprecated. Turn it on to study Remote File Inclusion, then turn it back off. Leaving it on permanently means every PHP application on this machine, including your own coursework, carries a class of vulnerability it otherwise would not.

10


VERIFY BINDING

Prove it is not reachable from the network

You bound Apache and MariaDB to localhost in Lab 02A. Verify it now, because this is the step that separates a lab from an incident, and configuration drifts:

bash
netstat -ano | findstr ":80 "
netstat -ano | findstr ":3306 "
# you want 127.0.0.1:80 and 127.0.0.1:3306
# 0.0.0.0:80 means every device on your network can reach DVWA

Then test it from the outside rather than trusting the output. From your phone on the same wifi, with wifi on and mobile data off, open http://YOUR-PC-IP/dvwa/. Find the IP with ipconfig. You want a connection error. If DVWA's login page loads on your phone, it is exposed — go back to Lab 02A Part 4 and fix the Listen directive before you do anything else. This is also a good moment to notice how easy that test was. Anyone else on that network can run it too.

11


STOP WHEN IDLE

Off by default

Stop Apache and MySQL when you finish a session. A deliberately vulnerable web application running every hour your laptop is on — in cafes, on campus, on hotel wifi — is a standing risk for no benefit. Two clicks in the Control Panel, or:

bash
net stop Apache2.4
net stop mysql

And keep the service checkboxes in the Control Panel unticked so neither starts with Windows.

12


ROLLBACK

Back up the config and the database

You are about to spend weeks deliberately breaking this application. Give yourself a five-second restore:

bash
# config + a database dump, from an administrator PowerShell
$b = "$HOME\dvwa-baseline"; mkdir $b -Force
copy C:\xampp\htdocs\dvwa\config\config.inc.php $b
C:\xampp\mysql\bin\mysqldump.exe -u dvwa -p dvwa > "$b\dvwa.sql"

# restore later:
# C:\xampp\mysql\bin\mysql.exe -u dvwa -p dvwa < "$b\dvwa.sql"

In practice, Create / Reset Database on setup.php handles most of what you will break. The dump matters when you have customised something and want it back. If you are running this inside the VM from Lab 01, a VirtualBox snapshot named dvwa-clean is faster than either.

WHEN IT BREAKS

Eight failures, sorted by what you see

Almost every one of these is the database connection or a file path. Read the actual error before you search for it — DVWA's messages are unusually honest.

"Could not connect to the MySQL service" on setup.php
Four candidates, in order. MySQL is not started in the Control Panel. db_server is set to localhost rather than 127.0.0.1, so PHP is trying IPv6 ::1 while MariaDB listens on IPv4. The dvwa user does not exist or was created for a different host — it must be 'dvwa'@'127.0.0.1' to match. Or the password in config.inc.php does not match the one you set in step 5. Test the credentials independently: mysql -u dvwa -p
"Access denied for user 'root'@'localhost'"
Your config is still on root, which is the older guides' advice. You gave root a password in Lab 02A and DVWA is presenting a blank one. Do not fix this by removing the root password. Do step 5 and step 6 — create the dvwa user and point the config at it.
The page is blank, or shows PHP code as plain text
Blank usually means a fatal PHP error with display_errors off — look in C:\xampp\apache\logs\error.log, which names the file and line. Seeing raw PHP source in the browser means Apache is not processing .php at all: you are either opening the file directly as file:/// rather than through http://localhost, or the file is outside htdocs.
404 on http://localhost/dvwa/setup.php
The folder name does not match the URL. Check C:\xampp\htdocs for DVWA-master rather than dvwa and rename it. Also confirm you did not nest it — htdocs\dvwa\DVWA-master\ is a common extraction result, and setup.php then sits one level deeper than you think.
setup.php says a folder is not writable
The hackable\uploads and config folders need write access for the file upload module and for DVWA to save state. If XAMPP is installed under C:\xampp this normally just works; if you installed into Program Files, UAC is blocking the writes and the real fix is moving XAMPP to C:\xampp as Lab 02A step 06 explains. Otherwise check the folder is not marked read-only in Properties.
Some modules error out, others work fine
Usually a PHP version mismatch between your XAMPP build and what the DVWA release supports. Check DVWA's README for the supported versions and compare against the version on http://localhost/dvwa/phpinfo.php. The File Inclusion modules are a separate case — they need allow_url_fopen and allow_url_include, which is step 9.
The login page loads but admin / password is rejected
The database exists but was not seeded, or you changed the password and forgot. Go back to http://localhost/dvwa/setup.php and press Create / Reset Database — that recreates the tables and restores the default credentials. Everything you did inside DVWA is lost, which is fine; that is what it is for.
It works on your laptop but a classmate's phone can load it too
That is the exposure case and it needs fixing now, not later. Apache is bound to 0.0.0.0. Edit C:\xampp\apache\conf\httpd.conf so the directive reads Listen 127.0.0.1:80, restart Apache, and re-run the phone test in step 10. Until it fails from the phone, treat the machine as exposed.

QUESTIONS FROM CLASS

Asked in every batch

Is installing DVWA legal?
Yes. DVWA is open-source software and installing it on a machine you own is no different from installing any other application. What is regulated is what you point your tools at: attacking systems you do not own and have no written authorisation to test is an offence under the Information Technology Act in India and comparable laws elsewhere. DVWA exists precisely so you have a target where that question does not arise.
Why can't I just use root with a blank password like the older guides say?
Because XAMPP ships MariaDB, and DVWA's own configuration file states that MariaDB users must create a dedicated account rather than using root. Beyond that, a blank password means undoing the database hardening from Lab 02A, and pointing a deliberately vulnerable application at a root account means a successful injection in your practice app owns every database on the machine. The dedicated user takes thirty seconds and costs you nothing.
DVWA or a hosted platform like Hack The Box and TryHackMe?
Both, in that order. DVWA runs locally, has no time limit, and its source code sits on your disk — so when a payload works you can open the file and read exactly why, then switch to Impossible and read the fix. That loop teaches more per hour than a scored box. Hosted platforms add realistic chains, network context and other people's write-ups. Start here, move there.
Should I run DVWA on Windows or inside the Kali VM?
Windows is fine for this lab, and the host-versus-target split is part of what you are learning: Kali is where you attack from, this is what you attack. But if the Windows machine is your everyday laptop, moving XAMPP and DVWA into their own VM on a host-only network is strictly safer — nothing vulnerable is ever bound to an interface your real network can reach. Lab 04 builds that.
Which security level should I use?
Low while you are learning the attack, Impossible afterwards to read the correct implementation. Medium and High are the interesting middle: they add partial, bypassable defences, which is a far better model of real applications than either extreme. Working the same module up through all four levels is the most useful thing you can do with DVWA.
Do I need the reCAPTCHA keys?
Only for the Insecure CAPTCHA module. setup.php will report the key as missing and everything else works normally. If you want that module, generate your own keys from Google's reCAPTCHA admin console and paste them into config.inc.php.
Can I put this on my college server so my whole class can use it?
No, and this is the one question in this FAQ with only one answer. DVWA is a working set of vulnerabilities; on a reachable server it is a live entry point into that machine and whatever network it sits on. Everyone installs their own local copy. It takes twenty minutes, which is the point of writing this guide.
Something is broken and I want to start over. Do I reinstall?
Almost never. Create / Reset Database on setup.php rebuilds the tables and restores the defaults, which fixes most of what you will break. If you have edited files, restore config.inc.php from the .dist template or from the baseline copy in step 12. Reinstalling XAMPP itself is a last resort and rarely the actual problem.

SOURCES & NOTES

Where this comes from

DVWA is published by Robin Wood (digininja) at github.com/digininja/DVWA. The database-user guidance in steps 5 and 6 comes from the comments in DVWA's own config.inc.php.dist and its README. XAMPP is published by Apache Friends. The corrections at the top of this page, the least-privilege reasoning, the isolation checks and the troubleshooting section come from our own classroom experience across student batches. Screenshots are Skills Uprise course material.

A NOTE ON THE SCREENSHOTS

These images were taken from an earlier version of this lesson. They still show the correct clicks, but the config screenshot shows the older root-with-blank-password approach that steps 5 and 6 now replace — which is why the corrections appear before the steps rather than after them. Worth re-capturing when you next record this lesson, on a current XAMPP build and a machine whose Windows username is not visible in the frame.


DVWA is licensed by its authors; see the repository for terms. XAMPP, Apache, MariaDB and PHP are the property of their respective projects. Skills Uprise is not affiliated with, endorsed by or sponsored by any of them.

LAB 02B COMPLETE

You have a target you are allowed to break.

Submit three screenshots for Lab 02B: setup.php with your dvwa database values, the DVWA main page after logging in, and netstat showing Apache bound to 127.0.0.1. The third one is the graded part — the whole lab is worthless if the target is reachable from outside your machine.

LAB 03

Your first SQL injection

Work the SQLi module from Low to Impossible, reading the source at every level.

LAB 04

An isolated host-only network

Move the target into its own VM so nothing vulnerable touches your real network.

LAB 02A

Install XAMPP on Windows

The stack this runs on, including the four hardening steps this lab depends on.

Read more articles →