Install DVWA on Kali Linux (Step-by-Step)

In this tutorial, I will give you a step-by-step guide on how to set up and install DVWA on your Kali Linux system.

When starting as a penetration tester, you will need a pentesting-lab to test out your penetration skills. One such system is the Damn Vulnerable Web Application (DVWA). DVWA is a vulnerable web application developed using PHP and MySQL that allows ethical hackers to test out their hacking skills and security tools.


It’s also an excellent guide for professional web developers with security in mind. They can use it to learn which features of a web application are easy to exploit. Some of the most common web vulnerabilities demonstrated by this application include Cross-Site Request Forgery (CSRF), File Inclusion, SQL injection, Bruteforce attacks, and much more.


Pre-requisites to install DVWA

This tutorial assumes that you already have a Kali Linux Server Up and Running.


Step 1: Download Damn Vulnerable Web Application (DVWA)

To get started, we will need to clone the DVWA GitHub into our /var/www/html directory. That is the location where Localhost files are stored in Linux systems. Launch the Terminal and change our directory to the /var/www/html directory with the command below.

$ cd /var/www/html

Sample Output:
Install DVWA on Kali Linux (Step-by-Step)

Once in this directory, we will clone the DVWA GitHub repository with the command below.

$ sudo git clone

Sample Output:
Install DVWA on Kali Linux (Step-by-Step)


After cloning, we can rename the DVWA folder to dvwa. That is not mandatory, but it makes work easier when executing multiple commands.

$ sudo mv DVWA dvwa


Step 2: Configure DVWA

After downloading cloning DVWA in our /var/www/html directory, we still need to do some minor configurations. To get started, let’s set read, write, and execute permissions to the DVWA directory. Execute the command below.

$ chmod -R 777 dvwa/

Sample Output:
Install DVWA on Kali Linux (Step-by-Step)

After successfully executing the command, we need to set up the user and password required to access the database. Change directory to point to the config directory with the command below.

$ cd dvwa/config

When you run the ls command to view the files inside the directory, you will see the file. That is the original file containing the default configurations. We won’t edit it. Instead, we will create a copy of this file called and the original file will act as our backup in case things go wrong.

Execute the command below.

sudo cp

Sample Output:
Install DVWA on Kali Linux (Step-by-Step)

Run the command below to open the newly created file with nano editor and make the necessary changes, as shown in the image below. We will set db_user as user and db_password as pass. Feel free to use a different username or password.

$ sudo nano

Sample Output:
Install DVWA on Kali Linux (Step-by-Step)

Save the file (Ctrl + O, then Enter) and Exit (Ctrl + X). That’s it! We are done configuring the DVWA Web application. Let’s move on and configure the database (MySQL).


Step 3: Install MySQL on Kali Linux

By default, MySQL comes pre-installed on Kali Linux. If that's not the case for you or maybe you messed up with MySQL, we can go ahead and install it manually. If you have worked with Debian-based distributions, MySQL comes in two packages:

  • mysql-server
  • mysql-client

In our case, we will need to install the mysql-server. However, there is a catch. If you try using the command apt install mysql-server you will most likely get the error "Package mysql-server is not available, but is referred to by another package. E: Package 'mysql-server' has no installation candidate." That's because the package mysql-server is referred to default-mysql-server in Kali Linux and also in the latest release of Debian (Debian 10). Therefore, use the command below:

sudo apt install default-mysql-server

Sample output:
Install DVWA on Kali Linux (Step-by-Step)


Step 4: Configure MySQL Database

Start the Mysql service with the command below:

$ sudo service mysql start

You can check whether the service is running using the systemctl status command below.

$ systemctl status mysql

Sample Output:
Install DVWA on Kali Linux (Step-by-Step)

Login to the MySQL database using the command below as root. If you have another name set for the superuser in your system, use it instead of root.

$ sudo mysql -u root -p

You will see a prompt to enter the password. Just hit Enter since we haven’t set any password. MySQL will open, as shown in the image below:
Install DVWA on Kali Linux (Step-by-Step)

We will create a new user with the username and password set in our DVWA application configuration file. In my case, the username was ‘user,' and the password was ‘pass.’ The server we are using is Localhost ( Use the command below.

create user 'user'@'' identified by 'pass';

Sample Output:
Install DVWA on Kali Linux (Step-by-Step)

We need to grant this new user privilege over the dvwa database. Execute the command below.

grant all privileges on dvwa.* to 'user'@'' identified by 'pass';

Up to this point, we are through with configuring both the DVWA application and the MySQL database. Type exit to close the database.
Install DVWA on Kali Linux (Step-by-Step)


Step 5: Install PHP

PHP comes installed in Kali Linux. However, if you want to install a particular version, you can do it manually from the Terminal. In this post, we will install PHP 7.4 which is the latest release as of writing this post. Follow the steps below.

First, update your system and add the SURY PHP PPA repository by executing the commands below.

sudo apt update
sudo apt -y install lsb-release apt-transport-https ca-certificates
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg
echo "deb buster main" | sudo tee /etc/apt/sources.list.d/php.list

Sample output:
Add SURY PHP PPA repository

After successfully adding the repository, use the command below to install PHP 7.4

sudo apt update
sudo apt install php7.4 -y

Sample output:
Install DVWA on Kali Linux (Step-by-Step)

To install additional PHP extensions, use the syntax below where xxx stands for the extension name.

sudo apt install php7.4-xxx
sudo apt install php7.4-{cli,json,imap,bcmath,bz2,intl,gd,mbstring,mysql,zip}

Sample output:
Install DVWA on Kali Linux (Step-by-Step)


Step 6: Configure Apache Server

Now, we need to configure the server. Use the command below to change your location on the Terminal to point to /etc/php/7.3/apache2 directory.

$ cd /etc/php/7.4/apache2

As of writing this post, I was running PHP version 7.4. You might need to confirm your version and replace it on the command. Use the command below to check the installed version.

$ ls /etc/php

In the /etc/php/7.4/apache2, when you execute the ls command, you will see a file called php.ini. That is the file we will edit to configure our localhost server. Use the command below to open it using the nano editor.

$ sudo nano php.ini

Scroll down and look for these two lines: allow_url_fopen and allow_url_include. Set them both as On. Save the file (Ctrl + O, then Enter) and Exit (Ctrl + X).

Install DVWA on Kali Linux (Step-by-Step)

Start Apache server using the command below:

$ sudo service apache2 start

To check whether the service started successfully, use the status command.

$ systemctl status apache2

Sample Output:
Install DVWA on Kali Linux (Step-by-Step)


Step 7: Access DVWA on Your Browser

That’s it! We now have everything configured, and we can proceed to launch DVWA. Open your browser and enter the URL:

That will open the setup.php web page as shown in the image:

Install DVWA on Kali Linux (Step-by-Step)


You might see the errors colored in red as in the image above. Don’t panic! Scroll down and click the Create / Reset Database button.

Install DVWA on Kali Linux (Step-by-Step)


That will create and configure the database. After some time, you will be redirected to the DVWA login page. Log in with these credentials:

  • Username - admin
  • Password - password

Install DVWA on Kali Linux (Step-by-Step)

Once logged in, you will see the DVWA main page. On the left panel, we have the different types of attacks you can exploit and the DVWA Security button that allows you to choose the desired security level - Low, Medium, High, or Impossible.

Install DVWA on Kali Linux (Step-by-Step)



That is how we install DVWA on Kali Linux. Pretty easy, right? DVWA is an excellent resource for both beginners getting started with Penetration Testing and experts. All you need to do is change the security levels depending on your skills. Feel free to share the vulnerability you found interesting to exploit with our readers in the comments section.

Didn't find what you were looking for? Perform a quick search across GoLinuxCloud

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can either use the comments section or contact me form.

Thank You for your support!!

Leave a Comment