In this tutorial, we are going to learn what is XAMPP stack and how to install XAMPP in Linux operating systems. Next, we will discuss how to start or restart XAMPP server and how to access XAMPP test page, phpMyAdmin dashboard. Finally, we will see how to secure XAMPP installation and remove XAMPP if it is no longer required.
Table of Contents
1. What is XAMPP Stack?
XAMPP is a completely free, and open source cross-platform Apache distribution developed by Apache Friends. The XAMPP is a Web server solution stack that allows you to easily install Apache, MariaDB, PHP, and Perl on GNU/Linux, Mac OS and Microsoft Windows.
The XAMPP is widely used by developers to test their web applications in their local system before uploading them to the production system.
XAMPP is short for Cross-platform (X), Apache Web server (A), MariaDB (M), PHP (P), and Perl (P).
2. Install XAMPP in Linux
The XAMPP installation steps are same for all Linux distributions. For the purpose of this guide, we will be using Debian 11 Bullseye.
Go to Apache Friends website and download the latest available version. As of writing this guide, the latest version was 8.1.4.
Once XAMMP is downloaded, go to the download location and make it executable.
$ cd Downloads
$ chmod +x xampp-linux-x64-8.1.4-1-installer.run
Or,
$ chmod 755 xampp-linux-x64-8.1.4-1-installer.run
XAMPP supports both CLI and GUI installation. So you can install XAMPP on Linux desktops and servers.
2.1. XAMPP CLI Installation
Run the following command to start XAMPP installer from command line:
$ sudo ./xampp-linux-x64-8.1.4-1-installer.run
You will prompted to answer a couple questions. Simply type "Y" to all questions and complete the installation.
---------------------------------------------------------------------------- Welcome to the XAMPP Setup Wizard. ---------------------------------------------------------------------------- Select the components you want to install; clear the components you do not want to install. Click Next when you are ready to continue. XAMPP Core Files : Y (Cannot be edited) XAMPP Developer Files [Y/n] :y Is the selection above correct? [Y/n]: y ---------------------------------------------------------------------------- Installation Directory XAMPP will be installed to /opt/lampp Press [Enter] to continue: ---------------------------------------------------------------------------- Setup is now ready to begin installing XAMPP on your computer. Do you want to continue? [Y/n]: ---------------------------------------------------------------------------- Please wait while Setup installs XAMPP on your computer. Installing 0% ______________ 50% ______________ 100% ######################################### ---------------------------------------------------------------------------- Setup has finished installing XAMPP on your computer.
By default, XAMPP is installed /opt/lampp/
directory.
Once the installation is completed, start XAMPP service with command.
$ sudo /opt/lampp/lampp start
Refer the "Start/Restart XAMPP Service" section below to know how to start, restart XAMPP modules.
2.2. XAMPP GUI Installation
Start XAMPP graphical setup wizard by running the following command:
$ sudo ./xampp-linux-x64-8.1.4-1-installer.run
The XAMPP installer wizard will open now. Click Next to continue.
Select the XAMPP components you want to install and click Next.
Now, the installer will display the default installation path of XAMPP. By default, XAMPP will be installed in /opt/lampp
directory. Click Next to continue.
Click Next to continue.
The XAMPP installation will start now.
XAMPP installation is completed now. if the "Launch XAMPP" box is checked, the XAMPP control panel will start automatically.
Please note that you will have to manually start XAMPP at every system reboot by running the following command:
$ sudo /opt/lampp/lampp start
You will now be greeted with XAMPP control panel welcome screen.
You can start the XAMPP control panel at any time by running the following command:
$ sudo /opt/lampp/manager-linux-x64.run
2.3. XAMPP Control Panel
As you can see in the above screenshot, the welcome screen shows the following 4 tabs. Clicking on each tab will get you to the respective section.
- Go To Application - Go to Application Window
- Open Application Folder - Take you to XAMPP application where the project are going to be saved. The default location is
/opt/lampp
. - Visit Apache Friends - Go to the XAMPP Home page
- Get Started - Display XAMPP help section.
2.3.1. Manage Servers
This section shows the list of modules that are running or stopped.
To start/restart a module, just select it and click Start/Restart buttons.
2.3.2. Application Log Section
This section shows logs related to the running applications.
3. Start / Restart XAMPP Service From CLI
As stated already, you should manually start XAMPP service at every system reboot.
To start XAMPP service from commandline, simply run:
$ sudo /opt/lampp/lampp start
You may see the following warning message.
Starting XAMPP for Linux 8.1.4-1... XAMPP: Starting Apache.../opt/lampp/share/xampp/xampplib: line 22: netstat: command not found /opt/lampp/share/xampp/xampplib: line 22: netstat: command not found ok. XAMPP: Starting MySQL.../opt/lampp/share/xampp/xampplib: line 22: netstat: command not found ok. XAMPP: Starting ProFTPD.../opt/lampp/share/xampp/xampplib: line 22: netstat: command not found ok.
As you can see in the above outpout, the netstat command is not available. Netstat is part of the "net-tools" package. To fix this, simply install net-tools package.
The net-tools package is available in the default repositories of most Linux distributions. For example, you can install net-tools on Debian-based system using the following command:
$ sudo apt install net-tools
Reboot the system and start XAMPP service again:
$ sudo /opt/lampp/lampp start
You should see all the services are running now.
Starting XAMPP for Linux 8.1.4-1... XAMPP: Starting Apache...ok. XAMPP: Starting MySQL...ok. XAMPP: Starting ProFTPD...ok.
You can check the status of XAMPP service using command:
$ sudo /opt/lampp/lampp status
Sample output"
Version: XAMPP for Linux 8.1.4-1 Apache is running. MySQL is running. ProFTPD is running.
To restart the XAMPP service, run:
$ sudo /opt/lampp/lampp restart
Sample Output:
Restarting XAMPP for Linux 8.1.4-1... XAMPP: Stopping Apache...ok. XAMPP: Stopping MySQL...ok. XAMPP: Stopping ProFTPD...ok. XAMPP: Starting Apache...ok. XAMPP: Starting MySQL...ok. XAMPP: Starting ProFTPD...ok.
4. Access XAMPP Web Dashboard
Open your web browser and navigate to http://localhost or http://IP-Address. You will be greeted with XAMPP test page.
Congratulations! We have successfully setup XAMPP stack in our Linux system. You can now start testing the web applications!
To view the PHP information, simply click PHPInfo link on the top from the XAMPP test page. Alternatively, you can directly navigate to http://localhost.phpinfo.php from your web browser.
5. Access PhpMyAdmin
To access phpMyAdmin dashboard, click the phpMyAdmin link from the XAMPP test page or directly navigate to http://localhost/phpmyadmin from the browser's address bar.
There is no password for phpMyAdmin. If you want to secure phpMyAdmin admin account, refer the "Secure XAMPP" section below.
5.1. Enable Remote Access To PhpMyAdmin
By default, phpMyAdmin can only be accessed from the localhost itself. If you want to access it from a remote system on the network, edit /opt/lampp/etc/extra/httpd-xampp.conf
file:
$ sudo nano /opt/lampp/etc/extra/httpd-xampp.conf
Find the following directive:
<Directory "/opt/lampp/phpmyadmin"> AllowOverride AuthConfig Limit Require local ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var </Directory>
Replace the line "Require local" with "Require all granted".
<Directory "/opt/lampp/phpmyadmin"> AllowOverride AuthConfig Limit Require all granted ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var </Directory>
Save the file and close it. Restart XAMPP service to take effect the changes.
You can now access the phpMyAdmin dashboard from any remote system on your local area network by navigating to http://IP-Address/phpmyadmin URL.
6. XAMPP Configuration Files
The main XAMPP configuration files are saved in the following files.
- Apache web server configuration file:
/opt/lampp/etc/httpd.conf
,/opt/lampp/etc/extra/httpd-xampp.conf
- MySQL configuration file:
/opt/lampp/etc/my.cnf
- PHP configuration file:
/opt/lampp/etc/php.ini
- ProFTPD configuration file:
/opt/lampp/etc/proftpd.conf
7. Secure XAMPP Installation
XAMPP is meant only for development purposes. By default, XAMPP has no passwords set and you should refrain from use it in production.
It has certain configuration settings that make it easy to develop locally but that are insecure if you want to have your installation accessible to others.
If you want have your XAMPP accessible from the internet, make sure you understand the implications and learn how to protect your site.
Alternatively, you can use LAMP or LEMP stacks which are similar packages which are more suitable for production.
To secure XAMPP Installation, run:
$ sudo /opt/lampp/lampp security
You will be prompted to answer a couple questions to secure XAMPP. Answer "Yes" to all the questions and set the password for MySQL root user, PhpMyAdmin admin user, and ProFTPD admin user.
XAMPP: Quick security check... XAMPP: MySQL is accessable via network. XAMPP: Normaly that's not recommended. Do you want me to turn it off? [yes] XAMPP: Turned off. XAMPP: Stopping MySQL...ok. XAMPP: Starting MySQL...ok. XAMPP: The MySQL/phpMyAdmin user pma has no password set!!! XAMPP: Do you want to set a password? [yes] XAMPP: Password: XAMPP: Password (again): XAMPP: Setting new MySQL pma password. XAMPP: Setting phpMyAdmin's pma password to the new one. XAMPP: MySQL has no root passwort set!!! XAMPP: Do you want to set a password? [yes] XAMPP: Write the password somewhere down to make sure you won't forget it!!! XAMPP: Password: XAMPP: Password (again): XAMPP: Setting new MySQL root password. XAMPP: Change phpMyAdmin's authentication method. XAMPP: The FTP password for user 'daemon' is still set to 'xampp'. XAMPP: Do you want to change the password? [yes] XAMPP: Password: XAMPP: Password (again): XAMPP: Reload ProFTPD...ok. XAMPP: Done.
XAMPP is secured now.
At this stage, you should have a local, secure web development environment with XAMPP.
8. Uninstall XAMPP
Go to the location where XAMPP is installed:
$ cd /opt/lampp/
And, run the following command to remove XAMPP stack from your system:
$ sudo ./uninstall
You will be prompted if you want to remove XAMPP including all the modules. Type "Y
" and hit enter to uninstall XAMPP.
Do you want to uninstall XAMPP and all of its modules? [Y/n]: y ---------------------------------------------------------------------------- Uninstall Status Uninstalling XAMPP 0% ______________ 50% ______________ 100% ######################################### Info: Uninstallation completed Press [Enter] to continue:
Finally, remove the XAMPP installation folder:
$ sudo rm -fr /opt/lampp/
Conclusion
In this guide, we discussed what is XAMPP, and how to install XAMPP in Linux operating systems. We also looked at how to start or restart XAMPP modules and how to access XAMPP test page, php info page, and phpMyAdmin dashboard. Finally, we saw how to secure XAMPP installation and then how to remove the XAMPP stack from a Linux system.