Install DVWA on Kali Linux

Tested on Kali GNU/Linux Rolling 2026.2 (kali-rolling)
Package dvwa 2.5-0kali1
php8.4 8.4.23-1
docker.io 28.5.2+dfsg4
docker-compose 2.40.3-3
Applies to Kali Linux
Privilege sudo or root
Scope Install DVWA from the Kali package, Docker Compose, or a manual web stack; start and stop the lab; initialize the database; access from an isolated VM network; and troubleshoot common errors. Does not cover exploitation walkthroughs, Burp configuration, or public deployment.
Related guides Pentest lab setup

Damn Vulnerable Web Application (DVWA) is a PHP and MariaDB web lab for practicing common web flaws in a controlled environment. After DVWA is running, authorized stress tests against the same listener include slow POST denial of service labs in DDoS attack example on loopback only. On current Kali rolling releases, the fastest path is the native dvwa package, which installs application files, PHP, MariaDB, a dedicated nginx configuration, systemd integration, and the dvwa-start / dvwa-stop helpers. Docker Compose tracks the upstream repository when you want a disposable container lab. A manual Apache stack remains useful when you want to see how the pieces fit together.

IMPORTANT
Run DVWA only on systems you own or are authorized to test. Keep it on localhost or an isolated lab network. Do not expose a vulnerable application on a bridged interface, public IP, or production LAN.

Choose a DVWA installation method

Method Best for Default URL Jump to
Kali package Fastest Kali-native setup http://127.0.0.1:42001 Kali package
Docker Compose Disposable upstream environment http://127.0.0.1:4280 Docker
Manual web stack Learning Apache, PHP, and MariaDB integration Custom (often http://127.0.0.1/dvwa/) Manual setup

The Kali package and the official Docker Compose file use different ports. Bookmark the URL that matches the method you chose so you do not open port 80 by habit when the package lab listens on 42001.


Install DVWA from the Kali repository

This is the primary walkthrough. The package installs DVWA under /usr/share/dvwa, ships nginx configuration under /etc/dvwa, depends on MariaDB and PHP 8.4, and registers dvwa.service. You do not need to add PHP 7.4, the SURY repository, or a separate Node.js runtime before installing it.

Check the available package

Refresh the package index so apt sees the current Kali rolling repository:

bash
sudo apt update

Query which dvwa version Kali offers:

bash
apt policy dvwa
output
dvwa:
  Installed: (none)
  Candidate: 2.5-0kali1
  Version table:
     2.5-0kali1 500
        500 http://http.kali.org/kali kali-rolling/main amd64 Packages

The Candidate line is the version apt install would pull. The amd64 Packages text identifies the repository index used on this Kali installation. Kali publishes dvwa as an architecture-independent package (Architecture: all in dpkg -s dvwa). If Candidate shows (none), verify that the system uses the kali-rolling repository and rerun sudo apt update.

Install DVWA

Install the package and its dependencies:

bash
sudo apt install -y dvwa

The install pulls in MariaDB server, nginx, PHP 8.4 with FPM and MySQL extensions, and Apache-related packages listed as dependencies. Application files land under /usr/share/dvwa, helpers under /usr/bin/dvwa-start and /usr/bin/dvwa-stop, and the unit file at /usr/lib/systemd/system/dvwa.service.

Confirm the installed version:

bash
dpkg-query -W dvwa
output
dvwa	2.5-0kali1

Start and access DVWA

Start the lab with the Kali helper:

bash
dvwa-start
output
┏━(Message from Kali developers)
┃
┃ Please wait for the dvwa service to start
┃
┃ [*] Web UI: http://127.0.0.1:42001
┃ [i] You might need to refresh your browser once it opens
┃
┗━

ERROR: Need to complete the first time setup to initialise database (after logging into DVWA)
- Default User    : admin
- Default Password: password

This message means the dvwa database exists but its application tables have not been initialized. Complete the web setup before treating it as an error. If ERROR: Missing DVWA database appears, check systemctl status dvwa mariadb and journalctl -u dvwa --no-pager because the service should create the database during startup.

Open DVWA in a browser on Kali:

text
http://127.0.0.1:42001

Default lab credentials after database creation:

text
Username: admin
Password: password

Verify the service

Check that systemd reports the service as running:

bash
systemctl status dvwa --no-pager
output
● dvwa.service - The Damn Vulnerable Web Application in its own nginx server
     Loaded: loaded (/usr/lib/systemd/system/dvwa.service; disabled; preset: disabled)
     Active: active (running) since Fri 2026-07-31 12:43:16 EDT; 4s ago
   Main PID: 37266 (nginx)

Confirm nginx is listening on port 42001:

bash
sudo ss -lntp | grep 42001
output
LISTEN 0  511  0.0.0.0:42001  0.0.0.0:*  users:(("nginx",pid=37266,fd=5))

Send an HTTP request to confirm the web UI responds:

bash
curl -I http://127.0.0.1:42001
output
HTTP/1.1 302 Found
Server: nginx/1.30.1
Location: login.php
Set-Cookie: PHPSESSID=...; path=/

A 302 redirect to login.php means PHP and nginx are serving the application. Complete database setup next if you have not already done so.

In a browser on Kali, open http://127.0.0.1:42001 and you should see the DVWA login page:

DVWA login page running on Kali Linux at port 42001


Configure the DVWA database (Kali package)

The Kali package does not require manual SQL grants before the first login. Use the web workflow only:

  1. Open http://127.0.0.1:42001 in a browser on Kali.
  2. Follow the setup link to the database configuration page.
  3. Click Create / Reset Database.
  4. Wait for the success message, then open the login page.
  5. Sign in with admin / password.
  6. Open DVWA Security and confirm you can change the security level.

If the button fails, check MariaDB with systemctl status mariadb and read journalctl -u dvwa --no-pager before editing SQL by hand.


Stop, restart, and update DVWA

These commands cover day-to-day lab use with the Kali package.

Stop the lab

bash
dvwa-stop

The helper stops dvwa.service and prints recent journal lines so you can confirm a clean shutdown.

Restart through systemd

When you want a hard restart without the browser helper:

bash
sudo systemctl restart dvwa

View logs

bash
journalctl -u dvwa --no-pager

Follow logs while troubleshooting startup:

bash
journalctl -u dvwa -f

Update the Kali package

bash
sudo apt update
bash
sudo apt install --only-upgrade dvwa

Check the installed build after an upgrade:

bash
dpkg-query -W dvwa

Why the service stays disabled

dvwa.service is disabled after package install. Kali treats DVWA as an on-demand lab application, not an always-on network service. dvwa-start starts MariaDB dependencies as needed and brings nginx up on port 42001. Use dvwa-stop when you finish practice so the vulnerable app is not left running unintentionally.


Install DVWA with Docker Compose

Docker Compose is the preferred alternative when you want the upstream repository layout or an environment you can delete with one command. The official compose.yml publishes port 4280 on loopback, not port 80 on the host.

This section assumes Docker Engine is available. For a full Docker install on Debian-family systems, see Install Docker on Debian.

Install Docker and Compose on Kali

Refresh indexes and install Docker from Kali's repository:

bash
sudo apt update
bash
sudo apt install -y docker.io docker-compose git curl

Enable and start the Docker daemon:

bash
sudo systemctl enable --now docker

Verify the client reports a server version:

bash
sudo docker version
output
Client:
 Version:           28.5.2+dfsg4
Server:
 Engine:
  Version:          28.5.2+dfsg4

Confirm Compose is available:

bash
docker compose version
output
Docker Compose version 2.40.3-3

Clone and start the official stack

Clone the upstream repository:

bash
git clone https://github.com/digininja/DVWA.git
bash
cd DVWA

Start the stack in the background:

bash
sudo docker compose up -d

The default Compose file pulls ghcr.io/digininja/dvwa:latest, starts MariaDB 10, and publishes Kali loopback port 4280. Its pull_policy: always setting uses the current prebuilt image unless you deliberately change the policy to build.

Compose starts dependencies in order but does not wait for the database or application to become ready. Poll loopback with a two-minute timeout:

bash
if timeout 120 bash -c \
    'until curl -fsSI http://127.0.0.1:4280 >/dev/null; do sleep 2; done'
then
    curl -I http://127.0.0.1:4280
else
    sudo docker compose ps
    sudo docker compose logs --tail=100
fi

When the readiness check succeeds, expect:

output
HTTP/1.1 302 Found
Location: login.php

A 302 Found response with Location: login.php means the container stack is ready for browser setup. If the timeout branch runs, read docker compose ps and the last log lines before retrying docker compose up -d.

Open DVWA in a browser on Kali:

text
http://127.0.0.1:4280

List running containers:

bash
sudo docker compose ps

Read startup logs when a container exits immediately:

bash
sudo docker compose logs

Stop and remove the stack:

bash
sudo docker compose down

Add -v when you also want to delete the database volume for a completely fresh instance.


Manual Apache, PHP, and MariaDB setup

Use this optional path when you want to assemble Apache, PHP, and MariaDB yourself. Skip it when the Kali package or Docker method already meets your lab goals.

Install the web stack from Kali repositories

Install current Kali PHP packages. Do not add external PHP repositories:

bash
sudo apt update
bash
sudo apt install -y apache2 mariadb-server php php-mysql php-gd libapache2-mod-php git

Confirm the PHP CLI version Kali installed:

bash
php --version
output
PHP 8.4.23 (cli) (built: Jul  2 2026 18:36:55) (NTS)

Enable and start MariaDB and Apache:

bash
sudo systemctl enable --now mariadb apache2

Deploy DVWA source files

Clone the repository into the web root:

bash
sudo git clone https://github.com/digininja/DVWA.git /var/www/html/dvwa

Copy the sample configuration:

bash
sudo cp /var/www/html/dvwa/config/config.inc.php.dist /var/www/html/dvwa/config/config.inc.php

Edit /var/www/html/dvwa/config/config.inc.php and set database host 127.0.0.1, database name dvwa, and the username and password you create in the next step.

Set ownership so Apache can read the tree:

bash
sudo chown -R www-data:www-data /var/www/html/dvwa

Create the database and user

Log in to MariaDB as root:

bash
sudo mariadb

Create a dedicated database and user with modern MariaDB syntax:

sql
CREATE DATABASE dvwa;
CREATE USER 'dvwa'@'localhost' IDENTIFIED BY 'dvwa_pass';
GRANT ALL PRIVILEGES ON dvwa.* TO 'dvwa'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Match the username and password in config.inc.php to the values you chose here.

Enable required PHP settings

Edit the Apache PHP configuration for your installed version. On Kali 2026.2 the path is /etc/php/8.4/apache2/php.ini:

bash
sudo nano /etc/php/8.4/apache2/php.ini

Set these directives to On:

ini
allow_url_fopen = On
allow_url_include = On
display_errors = On
display_startup_errors = On

The first two settings support the remote-file-inclusion lab modules. The last two expose PHP and database configuration errors during this local practice setup instead of leaving you with an unexplained blank page.

Restart Apache so PHP picks up the change:

bash
sudo systemctl restart apache2

Initialize DVWA in the browser

Open:

text
http://127.0.0.1/dvwa/

Click Create / Reset Database, then log in with admin / password. For generic Apache and MariaDB service administration beyond this lab, see systemctl command when managing apache2 and mariadb units.


Access DVWA from another lab VM

Loopback access is the safest default. Open http://127.0.0.1:42001 for the Kali package or http://127.0.0.1:4280 for Docker Compose inside the same Kali session.

When you need a second VM on an isolated network:

  • Attach both VMs to a Host-only or Internal virtual network.
  • Use the Kali VM IP from that network, not bridged access to your home LAN.
  • Confirm the listener with sudo ss -lntp | grep -E ':(42001|4280)\b'.

The listening address shown by ss does not by itself prove that another VM can reach DVWA. Kali's packaged nginx configuration denies non-loopback clients by default, even though the socket may show 0.0.0.0:42001.

For access from one isolated peer VM, add its address after allow 127.0.0.1; in both location blocks inside /etc/dvwa/vhost/dvwa-nginx.conf:

nginx
allow 127.0.0.1;
allow <PEER_VM_IP>;
deny all;

Validate the nginx configuration and restart DVWA:

bash
sudo nginx -t -c /etc/dvwa/nginx.conf
bash
sudo systemctl restart dvwa

From the peer VM, test reachability:

bash
curl -I http://<KALI_LAB_IP>:42001
output
HTTP/1.1 302 Found
Location: login.php

302 Found with Location: login.php confirms nginx and PHP accepted the remote request. A 403 Forbidden response usually means the peer address is still blocked by the deny all rule.

For Docker Compose, the default compose.yml binds 127.0.0.1:4280, so another VM cannot reach the web container until you change the host address. Replace the loopback binding with the Kali VM address on the isolated network:

yaml
ports:
  - "<KALI_LAB_IP>:4280:80"

Recreate the web container so Docker applies the changed mapping:

bash
sudo docker compose up -d --force-recreate

From the peer VM:

bash
curl -I http://<KALI_LAB_IP>:4280
output
HTTP/1.1 302 Found
Location: login.php
WARNING
Only add peer VM addresses on an isolated lab network you control. Do not widen these allow rules on a bridged interface or production LAN.

For proxy-based testing, start Burp Suite inside Kali and point the browser at the correct port for your install method.


Troubleshooting

Symptom Likely cause Fix
Unable to locate package dvwa Stale indexes or non-Kali repositories Run sudo apt update, then apt policy dvwa and confirm Candidate is not (none) on kali-rolling
dvwa-start: command not found Package not installed or broken PATH Run sudo apt install dvwa and confirm /usr/bin/dvwa-start exists with command -v dvwa-start
Port 42001 not listening Service stopped or MariaDB dependency failed Run dvwa-start, then systemctl status dvwa mariadb and journalctl -u dvwa --no-pager
Database setup fails on the web page MariaDB not running or wrong credentials in manual installs For the package, run systemctl status mariadb; for manual installs, verify config.inc.php matches the SQL user you created
Blank PHP page Missing PHP module or fatal PHP error For manual installs, install php-gd and php-mysql; read Apache error logs under /var/log/apache2/
Required PHP module missing Incomplete manual PHP install Run php -m and install the matching php8.4-* packages Kali provides
Apache or nginx port conflict Another service bound to port 80 or 42001 Run sudo ss -lntp and stop the conflicting unit before starting DVWA
Permission denied under the web root Wrong ownership on cloned files Run sudo chown -R www-data:www-data /var/www/html/dvwa for manual installs
Docker port 4280 already in use Another container or host service Run sudo ss -lntp | grep 4280 and change the left side of the ports mapping in compose.yml
docker compose not found Compose plugin not installed Install docker-compose from Kali or the Docker Compose plugin, then rerun docker compose version
toomanyrequests during docker compose up Docker Hub rate limit on mariadb:10 Authenticate to Docker Hub, retry later, or pre-pull docker.io/library/mariadb:10 before docker compose up -d
Browser opens port 80 but package uses 42001 Wrong bookmark or habit from other labs Use http://127.0.0.1:42001 for the Kali package and http://127.0.0.1:4280 for Docker Compose
Peer VM gets 403 Forbidden on port 42001 Packaged nginx allows only loopback by default Add the peer VM IP to both location blocks in /etc/dvwa/vhost/dvwa-nginx.conf, then sudo nginx -t -c /etc/dvwa/nginx.conf and sudo systemctl restart dvwa
dvwa-start prints setup message on first run Application tables not initialized yet Open the setup page and click Create / Reset Database. If ERROR: Missing DVWA database appears, check systemctl status dvwa mariadb and journalctl -u dvwa --no-pager

Reset or remove DVWA

Kali package

To reset DVWA's database content, open http://127.0.0.1:42001/setup.php and click Create / Reset Database. Restarting with dvwa-stop and dvwa-start restarts the services but preserves the existing database.

Remove the package and configuration:

bash
sudo apt purge -y dvwa

Docker Compose

From the cloned DVWA directory:

bash
sudo docker compose down -v

The -v flag deletes the MariaDB volume so the next docker compose up -d starts with an empty database.


References


Summary

On current Kali rolling releases, sudo apt install dvwa is the fastest supported path to a local DVWA lab. The package wires PHP 8.4, MariaDB, nginx, and systemd together, exposes the application on port 42001, and gives you dvwa-start and dvwa-stop for day-to-day use. Complete the database from the web UI with Create / Reset Database, then sign in with admin and password.

Docker Compose from the official repository is the practical alternative when you want an isolated stack you can tear down with docker compose down. Remember that upstream Docker publishes 4280 on loopback, not 42001. The manual Apache and MariaDB method is optional—it teaches how the components connect, but it is slower and easier to misconfigure than the packaged install.

Keep DVWA on localhost or a host-only lab network, add explicit nginx allow rules before peer VM access, and stop the service when you finish practice. When you are ready to work through flaws, continue with DVWA SQL injection or Damn Vulnerable Web Application exploits using the same lab instance.

Deepak Prasad

R&D Engineer

Founder of GoLinuxCloud with more than 15 years of expertise in Linux, Python, Go, Laravel, DevOps, Kubernetes, Git, Shell scripting, OpenShift, AWS, Networking, and Security. With extensive experience, he excels across development, DevOps, networking, and security, delivering robust and efficient solutions for diverse projects.

  • Go (programming language)
  • Python (programming language)
  • DevOps
  • Computer Security
  • Cloud Computing
  • Kubernetes
  • Linux
  • Ansible (software)