Enhancing Security for XAMPP: A Comprehensive Guide

XAMPP is an incredibly useful tool for web developers, providing an easy-to-install environment for testing web applications locally. However, like any web server software, it's crucial to take security seriously, especially if you intend to use it for development or testing purposes. In this guide, we'll explore a series of steps to enhance the security of your XAMPP installation.



PhpMyAdmin Warning: The $cfg['TempDir'] (/opt/lampp/phpmyadmin/tmp/) is not accessible. PhpMyAdmin is not able to cache templates and will be slow because of this. PhpMyAdmin - Error, Existing configuration file (/opt/lampp/phpmyadmin/config.inc.php) is not readable.

Add or modify the following lines at the beginning of the 

nano /etc/init.d/lampp script.


### BEGIN INIT INFO

# Provides:          xampp

# Required-Start:    $remote_fs $syslog

# Required-Stop:     $remote_fs $syslog

# Default-Start:     2 3 4 5

# Default-Stop:      0 1 6

# Short-Description: Start XAMPP at boot time

# Description:       Enable services provided by XAMPP.

### END INIT INFO

Add the script to the default runlevels and enable it.

sudo update-rc.d -f lampp defaults && sudo update-rc.d -f lampp enable

Reboot your system and XAMPP should start automatically.

#Alias /phpmyadmin "/opt/lampp/phpmyadmin" replace with below

Alias /lalatendu "/opt/lampp/phpmyadmin"

sudo /opt/lampp/bin/htpasswd -c /opt/lampp/phpmyadmin/.htpasswd lalatendu

nano /opt/lampp/phpmyadmin/.htaccess

AuthType Basic

AuthName "Restricted Area"

AuthUserFile /opt/lampp/phpmyadmin/.htpasswd

Require valid-user



Hiding Apache Version

To hide the Apache version information, follow these steps:

1. Open the `httpd-default.conf` file: 

   sudo nano /opt/lampp/etc/extra/httpd-default.conf  


2. Add the following lines to the file:

   ServerSignature Off

   ServerTokens Prod



To hide the PHP version information, you need to make changes to the PHP configuration. Here's how:

1. Open the `php.ini` file:  

sudo nano /opt/lampp/etc/php.ini

2. Find the `expose_php` directive and set it to `Off`:

expose_php = Off



1. Open the `httpd-default.conf` file:

   

sudo nano /opt/lampp/etc/extra/httpd-default.conf


2. Add the following lines to set the maximum number of requests and the timeout for Keep-Alive connections:


   MaxKeepAliveRequests 500

   KeepAliveTimeout 15



OR

sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /Applications/XAMPP/etc/ssl.key/YourDomainName.key.pem -out /Applications/XAMPP/etc/ssl.crt/YourDomainName.cert.pem



Some of Important XAMPP / LAMPP Configuration File List

sudo nano /opt/lampp/etc/my.cnf

sudo nano /opt/lampp/etc/php.ini

sudo nano /opt/lampp/etc/httpd.conf

sudo nano /opt/lampp/etc/proftpd.conf

sudo nano /opt/lampp/etc/extra/httpd-ssl.conf

sudo nano /opt/lampp/apache2/conf/httpd.conf

sudo nano /opt/lampp/etc/extra/httpd-default.conf

sudo nano /opt/lampp/etc/extra/httpd-vhosts.conf

sudo nano /opt/lampp/etc/extra/httpd-xampp.conf

sudo nano /opt/lampp/phpmyadmin/config.inc.php

sudo nano /opt/lampp/htdocs/wordpress/wp-config.php


Server configuration files, like those found in XAMPP, are critical components of your web environment. Making backup copies of these files is a good practice. Here's how to create backups for specific XAMPP configuration files:


sudo cp /opt/lampp/etc/my.cnf /opt/lampp/etc/my.cnf-bkp

sudo cp /opt/lampp/etc/php.ini /opt/lampp/etc/php.ini-bkp

sudo cp /opt/lampp/etc/httpd.conf /opt/lampp/etc/httpd.conf-bkp

sudo cp /opt/lampp/etc/proftpd.conf /opt/lampp/etc/proftpd.conf-bkp

sudo cp /opt/lampp/etc/extra/httpd-ssl.conf /opt/lampp/etc/extra/httpd-ssl.conf-bkp

sudo cp /opt/lampp/apache2/conf/httpd.conf /opt/lampp/apache2/conf/httpd.conf-bkp

sudo cp /opt/lampp/etc/extra/httpd-default.conf /opt/lampp/etc/extra/httpd-default.conf-bkp

sudo cp /opt/lampp/etc/extra/httpd-vhosts.conf /opt/lampp/etc/extra/httpd-vhosts.conf-bkp

sudo cp /opt/lampp/etc/extra/httpd-xampp.conf /opt/lampp/etc/extra/httpd-xampp.conf-bkp

sudo cp /opt/lampp/phpmyadmin/config.inc.php /opt/lampp/phpmyadmin/config.inc.php-bkp

sudo cp /opt/lampp/htdocs/wordpress/wp-config.php /opt/lampp/htdocs/wordpress/wp-config.php-bkp

# XAMPP ALIAS #

alias edmy.cnf='nano /opt/lampp/etc/my.cnf'

alias edphp.ini='nano /opt/lampp/etc/php.ini'

alias edhttpd='nano /opt/lampp/etc/httpd.conf'

alias edproftpd='nano /opt/lampp/etc/proftpd.conf'

alias edhttpdssl='nano /opt/lampp/etc/extra/httpd-ssl.conf'

alias edhttpddefault='nano /opt/lampp/etc/extra/httpd-default.conf'

alias edhttpdvhosts='nano /opt/lampp/etc/extra/httpd-vhosts.conf'

alias edhttpdxampp='nano /opt/lampp/etc/extra/httpd-xampp.conf'

alias edconfiginc='nano /opt/lampp/phpmyadmin/config.inc.php'

alias edwpconfig='nano /opt/lampp/htdocs/wordpress/wp-config.php'

alias lstart='sudo /opt/lampp/lampp start </dev/null &>/dev/null &'

alias lstop='sudo /opt/lampp/lampp stop </dev/null &>/dev/null &'

alias lrestart='sudo /opt/lampp/lampp restart </dev/null &>/dev/null &'

alias lstatus='sudo /opt/lampp/lampp status </dev/null &>/dev/null &'

alias htd='cd /opt/lampp/htdocs/websites'

Here are some steps you can take to harden your XAMPP installation: