Install XAMPP on Ubuntu

A XAMPP is one of the most popular cross-platform PHP development environment. It is an open source package that can be easily install and to use.

XAMPP stands for cross-platform (X), Apache (A), MariaDB (M), PHP (P), and Perl (P).

XAMPP has been used widely by developers and has been around here with huge support of community since more than 10 years. It’s currently available on Windows, Linux & Mac platforms while writing this article.

To download the Linux installer head over to the Download page. Here you will find latest release as well as previous versions.

While writing this article, the latest release version is 8.0.6. In this article, we will see how to install this open-source application in Ubuntu or Ubuntu-based distributions. Follow the same steps to install into other Ubuntu-based Distros.

Install XAMPP on Ubuntu or Ubuntu-based Distros

Download the XAMPP installer

Head over to XAMPP Home page and select XAMPP for Linux, that contains direct link that can be used for the latest version.

apachefriends.org
Source: apachefriends.org

Once it’s downloaded, open your terminal (Ctrl + Alt + T), head over to your directory where your installer has been saved and run the below commands with sudo privileges to change the permission.

sudo chmod 755 xampp-linux-*-installer.run

This command will give permission to the installer.

Note: Replace xampp-linux-*-installer.run with actual file name.

Run the XAMPP installer

sudo ./xampp-linux-*-installer.run

This command will start the installer wizard. Proceed with installation, make changes if you need. By default it will be installed in /opt/lampp/ directory, you can customize the installation directory too.

Install supporting package

sudo apt install net-tools -fy

This command will install netstat that is a part of the net-tools package.

Start, Stop & Restart Server

Start, Stop & Restart Server via command line aka CLI

  • Start the server with below command

    sudo /opt/lampp/lampp start
    
  • Stop the server with below command

    sudo /opt/lampp/lampp stop
    
  • Restart the server with below command

    sudo /opt/lampp/lampp restart
    

Start, Stop & Restart Server via Graphical User Interface aka GUI

  • Execute the below command to launch graphical manager
sudo /opt/lampp/manager-linux-x64.run

Create alias or shortcuts for commands for Bash Shell

Below command will create an alias for command for Bash shell, so you only need to use lamppStart to launch the graphical manager. You might need to reopen the terminal to use this newly added alias.

echo "alias lamppStart='cd /opt/lampp/ && sudo ./manager-linux-x64.run'" >> ~/.bashrc

Creating a launcher icon

With the below code, you can create it a launcher icon.

cat > ~/.local/share/applications/postman.desktop <<EOL
[Desktop Entry]
Version=1.2
Encoding=UTF-8
Name=XAMPP
Exec=sh -c "pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY sudo /opt/lampp/manager-linux-x64.run"
Icon=/opt/lampp/htdocs/favicon.ico
Terminal=false
Type=Application
Categories=Network;WebBrowser;Development;
MimeType=text/html
EOL

Uninstall XAMPP

  1. To uninstall XAMPP, open the terminal and navigate to the opt/lampp directory with the below command.
      cd /opt/lampp
    
  2. Execute the below command to uninstall XAMPP.
      sudo ./uninstall
    
  3. The prompt dialogue box will open asking for your confirmation to uninstall XAMPP and all of its modules.
  4. Finally, remove the lampp installation directory with below command.
      sudo rm –r /opt/lamp
    

Conclusion

After reading this article, you will be able install XAMPP on Ubuntu or Linux devices.

XAMPP allows you to set up a free development environment on your system. It is a set of tools that allows you to get your site up and running much easily & quickly. An alternative to installing and configuring individual components.

Hope you like this!

Keep helping and happy 😄 coding

Vishnu Damwala
Vishnu Damwala

A web geek, an industry experienced web developer & tutor/instructor residing in India 🇮🇳