Installation Documentation: DVWA (Damn Vulnerable Web App)
Environment: Ubuntu Server Technology: LAMP Stack (Linux, Apache, MySQL, PHP)
Environment: Ubuntu Server Technology: LAMP Stack (Linux, Apache, MySQL, PHP)
1. Prerequisites and Package Installation
Sección titulada «1. Prerrequisitos e Instalación de Paquetes»First, we will ensure that the web server, the database, and PHP are installed with the necessary extensions.
sudo apt updatesudo apt install apache2 mariadb-server mariadb-client php php-mysqli php-gd php-mbstring php-xml git composer -y# Nota: Aunque instalamos el paquete mariadb-server, en este entorno actúa como MySQL nativo.2. Code Deployment
Sección titulada «2. Despliegue del Código»We will clone the official repository into the web directory and assign permissions to the Apache user (www-data).
cd /var/www/html/sudo git clone [https://github.com/digininja/DVWA.git](https://github.com/digininja/DVWA.git) dvwasudo chown -R www-data:www-data /var/www/html/dvwa/sudo chmod -R 755 /var/www/html/dvwa/Dependency Installation (API)
Sección titulada «Instalación de dependencias (API)»To avoid errors in the API modules, we will install the Composer dependencies:
cd /var/www/html/dvwa/vulnerabilities/apisudo composer installsudo chown -R www-data:www-data vendor/3. Database Configuration (MySQL)
Sección titulada «3. Configuración de Base de Datos (MySQL)»We will create the database and the user manually.
Accessing MySQL:
sudo mysqlExecute SQL commands:
CREATE DATABASE dvwa;CREATE USER 'dvwa_user'@'localhost' IDENTIFIED BY 'password123!';GRANT ALL PRIVILEGES ON dvwa.* TO 'dvwa_user'@'localhost';FLUSH PRIVILEGES;EXIT;4. DVWA File Configuration
Sección titulada «4. Configuración de Archivos DVWA»A. PHP Configuration File
Sección titulada «A. Archivo de Configuración PHP»We will copy the example file and edit the credentials.
cd /var/www/html/dvwa/config/sudo cp config.inc.php.dist config.inc.phpsudo nano config.inc.phpWe will make the following changes:
db_user: ‘dvwa_user’db_password: ‘password123!’db_database: ‘dvwa’
B. PHP Configuration (php.ini)
Sección titulada «B. Configuración de PHP (php.ini)»To make the vulnerabilities work (LFI/RFI), we will edit php.ini:
sudo nano /etc/php/8.3/apache2/php.iniWe will make the following changes:
allow_url_fopen = Onallow_url_include = On
C. MySQL Compatibility Patch (CRITICAL)
Sección titulada «C. Parche de Compatibilidad MySQL (CRÍTICO)»DVWA is optimized for older MariaDB. To make it work on modern MySQL, we must correct the IF NOT EXISTS syntax that causes an error when creating columns.
File: /var/www/html/dvwa/dvwa/includes/DBMS/MySQL.phpAction: We will remove the phrase IF NOT EXISTS on lines ~68 and ~173.
Corrected code (example):
// Antes (Error)$alter_users = "ALTER TABLE users ADD COLUMN IF NOT EXISTS role VARCHAR(20) DEFAULT 'user';";
// Después (Corregido)$alter_users = "ALTER TABLE users ADD COLUMN role VARCHAR(20) DEFAULT 'user';";5. Completion
Sección titulada «5. Finalización»We will restart Apache:
sudo systemctl restart apache2We will access http://TU_IP/dvwa/setup.php via browser and click “Create / Reset Database”.

