XAMPP on Linux

XAMPP is a free, open-source Apache distribution that includes MySQL, PHP, and Perl. It's one of the easiest ways to set up a local web development environment on Linux. This guide will walk you through installation, configuration, and common commands to get you up and running quickly.
What is XAMPP?
XAMPP stands for Cross-Platform (X), Apache (A), MySQL (M), PHP (P), and Perl (P). It bundles these essential web development tools into a single package, eliminating the need to install and configure each component separately. Whether you're learning web development or building local projects, XAMPP provides a complete local server environment.
Installation
Step 1: Download XAMPP for Linux
First, you need to download the XAMPP installer for Linux from the official Apache Friends website:
Choose the latest version compatible with your system architecture (32-bit or 64-bit).
Step 2: Make the Installer Executable
After downloading, open a terminal in the directory where you downloaded the file and make it executable:
chmod +x xampp-linux-x64-8.0.7-0-installer.run
Replace xampp-linux-x64-8.0.7-0-installer.run with your downloaded file name if it differs.
Step 3: Run the Installer
Install XAMPP to your system using the following command:
sudo ./xampp-linux-x64-8.0.7-0-installer.run
Follow the on-screen prompts to complete the installation. By default, XAMPP installs to /opt/lampp/.
Creating a Command Line Shortcut
Typing the full path to XAMPP every time is inconvenient. Create a symbolic link to make the xampp command available from anywhere in your terminal.
Link XAMPP to Your Local Bin Directory
sudo ln -s /opt/lampp/xampp /usr/local/bin
After running this command, you can simply use xampp instead of typing the full path /opt/lampp/xampp.
How to Use XAMPP
XAMPP provides several commands to control your web services:
Starting Services
# Start all services (Apache, MySQL, etc.)
sudo xampp start
# Start Apache web server only
sudo xampp startapache
# Start MySQL database only
sudo xampp startmysql
Stopping Services
# Stop all services
sudo xampp stop
# Stop Apache web server only
sudo xampp stopapache
# Stop MySQL database only
sudo xampp stopmysql
Restarting Services
# Restart all services
sudo xampp restart
# Restart Apache only
sudo xampp restartapache
Checking Service Status
# Check status of all services
sudo xampp status
Changing the htdocs Directory
By default, XAMPP serves files from /opt/lampp/htdocs/. You may want to change this to a custom directory for better organization. Here's how:
Step 1: Create Your New Directory
First, create your desired directory structure:
mkdir -p ~/Documents/Learn/WEB/localhost/htdocs
Step 2: Move Files (If Needed)
If you have existing files in the default directory, move them to your new location:
mv /opt/lampp/htdocs/* ~/Documents/Learn/WEB/localhost/htdocs/
Step 3: Create a Symbolic Link
Remove the original directory and create a symbolic link pointing to your new location:
sudo rm -rf /opt/lampp/htdocs
sudo ln -s ~/Documents/Learn/WEB/localhost/htdocs/ /opt/lampp/htdocs
Now Apache will serve files from your custom directory.
Accessing XAMPP Control Panel
You can also use XAMPP's graphical control panel:
sudo /opt/lampp/manager-linux-x64.run &
This opens a GUI where you can start/stop services with buttons instead of commands.
Verification
After installing and starting XAMPP, verify everything is working:
- Open your browser and navigate to
http://localhost - You should see the XAMPP dashboard
- Check that Apache and MySQL are running (green indicators)
Common Issues and Fixes
Port Already in Use: If port 80 or 3306 are already in use, edit the XAMPP configuration files in /opt/lampp/etc/ to use different ports.
Permission Denied: Always use sudo when managing XAMPP services on Linux.
Next Steps
Now that XAMPP is installed, you can:
- Create PHP applications in your htdocs directory
- Set up databases using phpMyAdmin (accessible at
http://localhost/phpmyadmin) - Configure virtual hosts for multiple projects
- Start developing your web applications locally
XAMPP provides a solid foundation for web development on Linux. With this setup, you'll have a complete local environment to test and develop web applications before deploying them to production servers.