SERVERS

How to install XAMPP on Ubuntu (16.04+)

What is XAMPP?

As described in the xampp official website, XAMPP is an easy to install Apache distribution containing MariaDB, PHP. It basically sets up an apache server to run php scripts or applications on it, plus a MariaDB database (which is the updated form of MySQL databases). It comes all in a single installer with a bunch of extra tools and extensions already pre configured. In this guide we'll go step by step on the process of downloading and installing xampp and how to use it.

Step 1 Download the XAMPP installer

Go to this url https://www.apachefriends.org/download.html and check the XAMPP for Linux section. There are multiple versions available, the difference is mainly the PHP version. Select any version of your preference.

Step 2 Run the installer

To run the installer we first need to give it execution permissions, open a terminal window, go to the path where you've downloaded the installer and make it executable using the following command (in this case the file name is: xampp-linux-x64-7.2.0-0-installer.run change it to your file name).


sudo chmod +x xampp-linux-x64-7.2.0-0-installer.run

Then run the installer by typing the following:


sudo ./xampp-linux-x64-7.2.0-0-installer.run

You should see the setup wizard, follow the steps with default options and the installer will take care of the rest.

xampp setup wizard 1

 

At the end of the installation, you can choose to either launch or not XAMPP after you hit the finish button.

xampp setup wizard 2

 

Step 3 Testing the components

The main XAMPP window gives you a control room for your server applications where you can start them, stop it and even configure them, go to the manage servers tab to check the status of your applications. Now let's start apache web server and MySQL Database.

xampp manage servers

 

Testing apache

Open the web browser go to http://localhost/ it should load the default XAMPP website, this meaning our apache server is running.

xampp apache dashboard

 

Testing MySQL

Open the web browser go to http://localhost/phpmyadmin/ this will load phpMyAdmin which is a web application for managing MySql databases.

phpmyadmin

 

Testing PHP

To run php scripts in XAMPP you should place the php files in "/opt/lampp/htdocs" file location, then run them by visiting http://localhost/name_of_the_file.php

For example, let's quickly create a php script with the following commands:


sudo -s
echo '<?php phpinfo();' > /opt/lampp/htdocs/info.php

Those lines will first log us as a root and then create an info.php file that runs the phpinfo() function. Now open the web browser and go to http://localhost/info.php you should see the php information website.

php info website

 

Done!

Now you're ready to start developing php applications using your xampp environment.

Alex Perea

Web and software developer, passionate by technology and design. Autodidact and pleased to share any piece of knowledge.