How to Install XAMPP in Ubuntu 22.04
Unlike the Microsoft suite of development tools, manually installing the tools to start PHP development can be a very tedious task. Luckily, there are software bundles like XAMPP that make the whole process much easier. Each letter of the name after X stands for Apache web server, MySQL for data storage along with the scripting languages PHP and Perl.
Also included are other useful tools such as FTP server FileZilla, Mercury Mail Transport System, Tomcat for Java apps, Webalizer, and Fake Sendmail along with the phpMyAdmin dashboard bundled with OpenSSL encryption. You can easily manage all of these tools through the central XAMPP control panel.
So, how can you leverage this bundle for PHP development on Ubuntu 22.04? Let’s explore the XAMPP installation process for users.
For you to follow through with this guide, you need:
– A graphical installation of Ubuntu 22.04 LTS
– A user account with sudo privileges
Let’s get right into it.
Before we start installing XAMPP, we need to download the installation package (well duh!). So, let’s head over to the XAMPP website, and then navigate to the downloads page. You’ll need to scroll down to the XAMPP for Linux section and select the package as per your requirements.
At the time of writing this guide, the latest version of PHP is 8.1.10, but if you want to target any specific version, you can download any other package. Click on the corresponding download button to kick off the process. Once the installer has been downloaded, let’s fire up the terminal and get to the next step.
Running the installer
Open up your terminal in the download directory and update the permissions of the installer to allow it to make changes to your system. You need to run:
$chmod 755 xampp-linux-x64-8.1.10-0-installer.run
After you’ve updated the permissions, you can run the installer using:
Navigating the Wizard
When you run the installer, you will be greeted by a wizard. You can click on “Forward” on the first screen. For the component selection, you need to select both the “Core Files” along with “Developer Files” and then press forward to proceed.
The next screen will show you the default installation directory i.e. /opt/lamp.
After these, the setup will install the components at the specified location, and you’ll be done with the installation.
Launching the control panel
After the installation, you are now ready to launch the XAMPP control panel and start launching the servers and the relevant applications. For the first time, you can launch XAMPP directly from the last screen of the installation wizard.
If you want to launch XAMPP through the terminal, you need to navigate to the ‘/opt/lamp’ directory and then run:
$sudo /opt/lampp ./manager-linux-x64.run
If you want a shortcut located on your desktop to enable you to easily launch XAMPP, you need to create a new file. Type the following in your terminal:
In the file, you need to paste the following details that define what type of shortcut this is going to be along with the path to the executable and its icon.
[Desktop Entry] Encoding=UTF-8 Name=XAMPP Control Panel Comment=Start and Stop XAMPP Exec=sudo /opt/lampp/manager-linux-x64.run Icon=/opt/lampp/htdocs/favicon.ico Categories=Application Type=Application Terminal=True
Save your file by pressing “Ctrl+O” and then Enter, and then exit from the file using “Ctrl+X”. As soon as you save the file, you’ll see a new icon created on your desktop for XAMPP as shown in the screenshot.
Now you need to give the newly created shortcut launching permissions. Right-click on the icon and go into properties.
Now go into the permissions tab and select the check box for “Allow executing file as program”.
Now close this dialog box and right click on the icon again and select “Allow Launching”
That’s it. Your desktop shortcut is ready to just double-click and launch XAMPP.
If you want to access it through the applications, you need to run the following to create an application launcher for it:
$sudo cp ~/Desktop/XAMPP.desktop /usr/share/applications/
Testing the installation
Before you get started with any development work, let’s make sure that your installation doesn’t have any issues by launching the applications. If you want to start all the services through the terminal, run:
$sudo /opt/lampp/lampp start
If you don’t get any errors, you can head on over to your web browser and type in “http://localhost/dashboard” in the address bar to access the Apache Web Server Dashboard.
Similarly, in your address bar type “http://localhost/phpmyadmin” to access the phpMyAdmin page.
When you are done working on the project or just want to stop all the services you can run:
$sudo /opt/lamp/lamp stop
This process can also be handled through the control panel. You get a visual representation of which applications are running and which need starting up. You can do that by the respective buttons on the control panel, and to be honest, it is easier than tinkering around with commands in the terminal.
When these pages load, it means that your installation doesn’t have any issues and you can start developing PHP applications on your Ubuntu 22.04.
If you are done with your project and want to remove XAMPP from your Ubuntu 22.04, you can easily uninstall it from your computer. The installation comes with a script for this exact purpose. You can run it from the ‘/opt/lampp’ directory using:
When you execute this, you will be asked to confirm if you want to remove XAMPP and all of its modules from your Ubuntu 22.04.
As soon as you confirm, the process will continue, and quickly inform you when it is done.
After you’ve uninstalled XAMPP, there’s no use for the shortcuts as well. You can remove the desktop shortcut using:
$sudo rm ~/Desktop/XAMPP-Control-Panel.desktop
After that you can remove the application launcher using:
$sudo rm /usr/share/applications/XAMPP-Control-Panel.desktop
XAMPP is a robust application bundle that allows you to locally host your developed applications on your Ubuntu 22.04 system. It makes the process of manually installing all the tools a lot easier.
If you’ve followed the guide without any errors, you now know the complete lifecycle of XAMPP on Ubuntu 22.04. If you run into any errors at any step of the guide, feel free to engage us through the comments section below and we’ll be more than glad to help you out. Let us know your thoughts and comments below. Cheers.