Installing XAMMP on a Linux distribution poses a moderate challenge for many people, including me. To make my life simple, I decided to code a BASH script to setup my machine whenever I format my SSD – it saves a ton of time and effort to have a simple program that downloads and install all the software I need to work, study and entertain myself. XAMMP is among those Linux applications.
In this article, I will show you how to build a BASH script and run it so you don’t have to manually type all commands in the terminal every time you want to install the software. This is a “do as I do” kind of tutorial, which means I won’t tell you what is BASH and how it works, I’ll just give you the code and show how to run.
You can learn more about BASH in this link.
For now, just know that your Linux distribution probably have BASH installed by default, and that is all you will need for keeping up with this tutorial. If you want to make sure BASH is installed in your machine, just type the following in the terminal:
You should receive the following output:
Now that we know for sure that BASH is installed, let’s create a file called xammp.sh and open it in a text or code editor. In my case, I allways use VS Code, but you are free to choose your favorite pick. With the file opened, paste the following code inside it:
This script will download the XAMMP installer file, make It installable and run It right after. To execute the script, open a terminal and browse to the directory where you placed xammp.sh. If don’t know how to browse your file system trhough the terminal, just open the file browser, go to the required folder, right click and select “Run on terminal”. After that, give the following command.
If you did everything right, you should see the screen bellow.
Just follow the wizard and install the software. After installation, XAMMP will launch and you will be able to use It normaly, if not one laste detail – there is no shortcut for the application. You can build one yourself through the terminal, but there is a easier solution. If you are using Ubuntu, Mint, or any Debian distribution, go to your desktop, righclick anywhere and select “Create new launcher”. A launcher can store terminal commands and run them upon shortcut click, and that is what we are doing for XAMMP.
First, open the XAMMP root directory, normaly /opt/lammp/. Second, search for a file called manager-linux-x64.run. The file may have a different name depending on the version you installed, but for this one this is the correct name. Now, you have to pass the following command to your launcher.
Your launcher will look like this.
Don’t forget to mark the “Run in the terminal?” checkbox before saving and you are good to go. Test your launcher and start developing your applications!