How To

Install XAMPP on Ubuntu 24.04 / 22.04 (All PHP Editions)

XAMPP bundles Apache, MariaDB, PHP, phpMyAdmin, and Perl into a single installer that gets a full local web development stack running in under five minutes. Whether you’re prototyping a WordPress site, testing a Laravel app, or just need a quick LAMP environment without touching your system packages, XAMPP handles the heavy lifting.

Original content from computingforgeeks.com - post 76194

This guide walks through installing any of the three available PHP editions on Ubuntu 24.04 and 22.04, configuring auto-start with systemd, deploying WordPress as a practical test, and upgrading to PHP 8.3 or 8.4 when XAMPP’s bundled version isn’t enough. If you’re on a different distro, check out the Debian guide or the Rocky/AlmaLinux guide.

Tested April 2026 on Ubuntu 24.04.4 LTS with XAMPP 8.2.12 (PHP 8.2.12, Apache 2.4.58, MariaDB 10.4.32)

Prerequisites

You need a running Ubuntu 24.04 or 22.04 system (desktop or server), a user account with sudo privileges, and an active internet connection to download the installer. Make sure no existing Apache, MySQL, or MariaDB service is running on the system to avoid port conflicts.

Choose Your PHP Edition

XAMPP ships three separate installers, each built around a different PHP version. Set a variable for the one you want:

export PHP_VER="8.2.12"  # Options: 8.2.12, 8.1.25, 8.0.30 (check Apache Friends for updates)

Pick 8.2 for new projects since it’s the latest actively supported release with performance improvements and fibers. Go with 8.1 if your application needs a stable, well-tested runtime that most frameworks already support. Choose 8.0 only for legacy applications that haven’t been updated for newer PHP versions (keep in mind PHP 8.0 reached end of life in November 2023).

Download and Install XAMPP

Grab the installer from SourceForge using the version variable:

wget "https://sourceforge.net/projects/xampp/files/XAMPP%20Linux/${PHP_VER}/xampp-linux-x64-${PHP_VER}-0-installer.run/download" -O xampp-installer.run

Make the installer executable and run it in unattended mode:

chmod +x xampp-installer.run
sudo ./xampp-installer.run --mode unattended

The --mode unattended flag skips the graphical installer wizard and runs everything silently. The entire stack installs to /opt/lampp within about a minute, depending on your disk speed.

Start XAMPP

Fire up all services with a single command:

sudo /opt/lampp/lampp start

You should see all three services come up cleanly:

Starting XAMPP for Linux 8.2.12-0...
XAMPP: Starting Apache...ok.
XAMPP: Starting MySQL...ok.
XAMPP: Starting ProFTPD...ok.

If Apache or MySQL fails to start, the most common cause is another service already occupying port 80 or 3306. We’ll cover that in the troubleshooting section below.

Verify Installed Versions

Confirm the exact versions XAMPP installed. Check PHP first:

/opt/lampp/bin/php -v

The output confirms PHP 8.2.12:

PHP 8.2.12 (cli) (built: Oct 24 2023 21:15:15) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.12, Copyright (c) Zend Technologies

Check the MariaDB version:

/opt/lampp/bin/mysql --version

This shows MariaDB 10.4.32 bundled with XAMPP:

/opt/lampp/bin/mysql  Ver 15.1 Distrib 10.4.32-MariaDB, for Linux (x86_64) using readline 5.1

And verify Apache:

/opt/lampp/bin/httpd -v

Apache 2.4.58 is running:

Server version: Apache/2.4.58 (Unix)
Server built:   Oct 24 2023 20:52:15

Access the XAMPP Dashboard

Open http://localhost/dashboard/ in your browser. The default XAMPP dashboard loads with links to phpMyAdmin, FAQs, and the HOW-TO guides.

XAMPP Dashboard on Ubuntu 24.04

Access phpMyAdmin

Navigate to http://localhost/phpmyadmin/ to manage databases through the web interface. By default, phpMyAdmin connects as root with no password.

phpMyAdmin on XAMPP Ubuntu

We’ll lock this down with a password in the security hardening section.

Test PHP Processing

Create a quick phpinfo page to confirm Apache is processing PHP correctly:

echo '<?php phpinfo(); ?>' | sudo tee /opt/lampp/htdocs/test.php

Open http://localhost/test.php in your browser. The full PHP configuration page should load, showing all compiled modules, loaded extensions, and environment variables.

PHP Info page on XAMPP

Remove this file when you’re done testing. Leaving phpinfo() exposed is a security risk since it reveals your entire server configuration.

sudo rm /opt/lampp/htdocs/test.php

Auto-Start XAMPP on Boot

XAMPP doesn’t ship with a systemd unit file, so it won’t survive a reboot by default. Create one:

sudo printf '[Unit]\nDescription=XAMPP\nAfter=network.target\n\n[Service]\nType=forking\nExecStart=/opt/lampp/lampp start\nExecStop=/opt/lampp/lampp stop\n\n[Install]\nWantedBy=multi-user.target\n' | sudo tee /etc/systemd/system/xampp.service

Reload systemd and enable the service:

sudo systemctl daemon-reload
sudo systemctl enable xampp

XAMPP will now start automatically after every reboot. You can also manage it with standard systemd commands like sudo systemctl restart xampp and sudo systemctl status xampp.

Security Hardening

Out of the box, XAMPP runs with no root password on MariaDB, open phpMyAdmin access, and an unsecured FTP server. Fix all of that in one step:

sudo /opt/lampp/lampp security

This interactive script walks you through setting passwords for the MySQL root account, phpMyAdmin access, and the ProFTPD user. Answer each prompt and set strong passwords. This is especially important if other users share the machine or if the system is reachable on a network.

Deploy WordPress on XAMPP

A practical way to validate your XAMPP stack is to deploy a real application. WordPress is the obvious choice since it exercises PHP, MariaDB, and Apache together.

Create the Database

Use the bundled MySQL client to set up a dedicated database and user:

/opt/lampp/bin/mysql -u root -e "CREATE DATABASE wordpress;"
/opt/lampp/bin/mysql -u root -e "CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'StrongP@ss';"
/opt/lampp/bin/mysql -u root -e "GRANT ALL ON wordpress.* TO 'wpuser'@'localhost';"

If you already set a root password with lampp security, append -p to each command and enter the password when prompted.

Download WordPress

Grab the latest release and extract it into the web root:

cd /opt/lampp/htdocs
sudo wget -q https://wordpress.org/latest.tar.gz
sudo tar xzf latest.tar.gz
sudo rm latest.tar.gz

Copy the sample config file so WordPress can find its settings:

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

Configure Database Credentials

Open the config file in your preferred editor:

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

Find and update these three lines to match the database you created:

define( 'DB_NAME', 'wordpress' );
define( 'DB_USER', 'wpuser' );
define( 'DB_PASSWORD', 'StrongP@ss' );

Set the correct ownership so Apache can write to the WordPress directory:

sudo chown -R daemon:daemon /opt/lampp/htdocs/wordpress/

XAMPP runs Apache as the daemon user, which is why the ownership target isn’t www-data like a standard Ubuntu Apache install.

Complete the WordPress Setup

Open http://localhost/wordpress/ in your browser. The WordPress installer loads with language selection, site title, and admin account creation. Fill in the details and click Install.

WordPress setup on XAMPP Ubuntu

Once the installation finishes, you’ll have a fully functional WordPress site running on your local XAMPP stack. Log in at http://localhost/wordpress/wp-admin/ to access the dashboard.

Upgrading PHP to 8.3 or 8.4

The official XAMPP Linux installers currently top out at PHP 8.2.12. There are no 8.3 or 8.4 builds available from Apache Friends for Linux. If your application requires a newer PHP version, you have two realistic options.

The first is compiling PHP from source. Download the tarball from php.net, configure it with the same flags XAMPP uses (check with /opt/lampp/bin/php -i | grep configure), and replace the binaries under /opt/lampp/bin/ and /opt/lampp/lib/php/. This works but is fragile. XAMPP’s internal components expect specific PHP versions, and swapping binaries can break phpMyAdmin or the control panel.

The second and more practical approach is dropping XAMPP entirely and using native Ubuntu packages. The ondrej/php PPA provides PHP 8.3 and 8.4 packages that integrate cleanly with the system Apache and MariaDB:

sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php8.4 libapache2-mod-php8.4 php8.4-mysql

This gives you a production-grade setup with proper package management and security updates. For development environments where XAMPP’s convenience isn’t a strict requirement, native packages are the better long-term choice.

Troubleshooting

Port 80 already in use

XAMPP’s Apache needs port 80, which conflicts with any existing web server on the system. If Apache fails to start, stop the conflicting service first:

sudo systemctl stop apache2
sudo systemctl disable apache2

For Nginx, the commands are similar:

sudo systemctl stop nginx
sudo systemctl disable nginx

After stopping the conflicting service, restart XAMPP with sudo /opt/lampp/lampp restart. You can verify what’s holding port 80 with sudo lsof -i :80 if the problem persists.

MySQL socket error

If XAMPP’s MySQL refuses to start with a socket error, check whether the system’s own MySQL or MariaDB service is already running:

sudo systemctl stop mysql
sudo systemctl disable mysql

On systems with MariaDB installed via apt, use sudo systemctl stop mariadb instead. Both services bind to port 3306 by default, which prevents XAMPP’s bundled MariaDB from starting.

Permission denied on htdocs

If PHP applications can’t write files (uploads, cache, logs), the ownership is wrong. XAMPP’s Apache runs as the daemon user:

sudo chown -R daemon:daemon /opt/lampp/htdocs/your-app/

Don’t use chmod 777 as a shortcut. Setting proper ownership is the correct fix.

Uninstall XAMPP

If you need to remove XAMPP completely, stop all services first and then delete the installation directory along with the systemd unit file:

sudo /opt/lampp/lampp stop
sudo rm -rf /opt/lampp
sudo rm /etc/systemd/system/xampp.service
sudo systemctl daemon-reload

This removes everything XAMPP installed, including all databases and web files under /opt/lampp/htdocs/. Back up any projects you want to keep before running these commands.

Related Articles

AI Install Ollama on Ubuntu 26.04 LTS with Open WebUI VPN Install Cisco AnyConnect VPN on Ubuntu, Debian, and Fedora Automation Install CatLight on Ubuntu / Debian / Linux Mint KVM Install KVM Hypervisor on Ubuntu 24.04|22.04|20.04

Leave a Comment

Press ESC to close