Installing Apache2, PHP, phpMyAdmin and ModSecurity on Debian 13
Posted: Sat Apr 25, 2026 10:59 am
Installing Apache2, PHP, phpMyAdmin and ModSecurity on Debian 13
This guide shows how to install a complete web server stack on Debian 13, including:
1. Update the System
2. Install Apache2
Start and enable Apache:
Check status:
Test in browser:
http://your-server-ip
3. Install PHP
Debian 13 typically ships with PHP 8.4+
Enable PHP in Apache:
Test PHP:
Open:
http://your-server-ip/info.php
4. Install MariaDB (Database)
Secure installation:
5. Install phpMyAdmin
During installation:
Access in browser:
http://your-server-ip/phpmyadmin
6. Install ModSecurity (WAF)
Enable module:
Check status:
7. Enable OWASP Core Rule Set
Install rules:
Copy config:
Edit main config:
Change:
to:
Restart Apache:
8. Recommended Security Settings
Edit Apache config:
Set:
Enable headers module:
Add security headers:
Reload Apache:
9. Firewall (Optional but Recommended)
If using UFW:
10. Final Check
Conclusion
You now have a fully functional and secured LAMP stack on Debian 13 with:
This guide shows how to install a complete web server stack on Debian 13, including:
- Apache2 (Web Server)
- PHP (Backend language)
- phpMyAdmin (Database management)
- ModSecurity (Web Application Firewall)
1. Update the System
Code: Select all
apt update && apt upgrade -y
2. Install Apache2
Code: Select all
apt install apache2 -y
Code: Select all
systemctl enable apache2
systemctl start apache2
Code: Select all
systemctl status apache2
http://your-server-ip
3. Install PHP
Debian 13 typically ships with PHP 8.4+
Code: Select all
apt install php php-cli php-fpm php-mysql php-curl php-gd php-xml php-mbstring php-zip php-intl -y
Code: Select all
a2enmod proxy_fcgi setenvif
a2enconf php*-fpm
systemctl reload apache2
Code: Select all
echo "<?php phpinfo(); ?>" > /var/www/html/info.php
http://your-server-ip/info.php
4. Install MariaDB (Database)
Code: Select all
apt install mariadb-server -y
Code: Select all
mysql_secure_installation
Code: Select all
apt install phpmyadmin -y
- Select Apache2
- Choose "Yes" for dbconfig-common
Code: Select all
ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin
http://your-server-ip/phpmyadmin
6. Install ModSecurity (WAF)
Code: Select all
apt install libapache2-mod-security2 -y
Code: Select all
a2enmod security2
systemctl restart apache2
Code: Select all
apache2ctl -M | grep security
Install rules:
Code: Select all
apt install modsecurity-crs -y
Code: Select all
cp /usr/share/modsecurity-crs/crs-setup.conf.example /etc/modsecurity/crs/crs-setup.conf
Code: Select all
nano /etc/modsecurity/modsecurity.conf
Code: Select all
SecRuleEngine DetectionOnly
Code: Select all
SecRuleEngine On
Code: Select all
systemctl restart apache2
Edit Apache config:
Code: Select all
nano /etc/apache2/conf-available/security.conf
Code: Select all
ServerTokens Prod
ServerSignature Off
Code: Select all
a2enmod headers
Code: Select all
Header always set X-Frame-Options "DENY"
Header always set X-Content-Type-Options "nosniff"
Header always set X-XSS-Protection "1; mode=block"
Code: Select all
systemctl reload apache2
9. Firewall (Optional but Recommended)
If using UFW:
Code: Select all
ufw allow OpenSSH
ufw allow 80/tcp
ufw allow 443/tcp
ufw enable
10. Final Check
- Apache running
- PHP working (info.php test)
- MariaDB secured
- phpMyAdmin accessible
- ModSecurity active
Conclusion
You now have a fully functional and secured LAMP stack on Debian 13 with:
- Apache2 as web server
- PHP for dynamic content
- MariaDB database
- phpMyAdmin for easy management
- ModSecurity as Web Application Firewall