> ## Content Index
> Fetch the complete content index at: https://itsfoss.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# How to Install and Use XAMPP on Ubuntu
- URL: https://itsfoss.com/install-xampp-ubuntu/
- Published: 2022-10-04T12:22:00.000Z
- Updated: 2023-01-01T12:24:29.000Z
- Description: Learn to install and use XAMPP on Ubuntu for deploying websites and web applications on localhost for development and testing.
- Author: Sagar Sharma
- Tags: Installation 📥

The purpose of XAMPP is to enable you to test your projects by setting up a local server, giving you a better understanding of how they will function when made available online.

And if you are curious about what XAMPP has to offer, have a look at its abbreviation:

- X: Cross-platform, means you can use it on almost every operating system.
- A: Apache server.
- M: MariaDB for database operations.
- P: PHP that you may want to use for dynamic websites.
- P: Perl programming language.

This makes the **XAMPP a complete package**, which is why people want to have it since it saves you a tonne of time, so you can later peacefully copy codes from StackOverflow (just kidding).

In this tutorial, I'll teach you the following:

- Installing XAMPP on Ubuntu
- Using it to host websites locally
- Removing it from the system

Sounds good? Let's go with the installation part.

## Install XAMPP in Ubuntu

XAMPP is available in various versions which consist of different versions of Apache, MariaDB, and others so you can go with what your workflow demands.

### Step 1\. Download the XAMPP binary File

To download XAMPP binary file, [visit their official download page](https://www.apachefriends.org/download.html?ref=itsfoss.com) and select the preferred version:

![download binary file for xampp in ubuntu](https://itsfoss.com/content/images/wordpress/2022/11/download-binary-file-for-xampp-in-ubuntu.png)

### Step 2\. Execute binaries

Open your file manager and open the Downloads directory as per default settings, the binary files must be located under the Downloads directory.

Now, select the XAMPP binary and press `Ctrl + i` and click on the `Permission` tab. From there, enable the option to execute the file as a program:

![allow binaries to execute in linux](https://itsfoss.com/content/images/wordpress/2022/11/allow-binaries-to-execute-in-linux.png)

Sure, you can do the same [using the chmod command](https://linuxhandbook.com/chmod-command/?ref=itsfoss.com):

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

And now, you can use the given command to run the installer:

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

Once executed, you will be met with the welcome screen:

![1. welcome to xampp setup wizard](https://itsfoss.com/content/images/wordpress/2022/11/1.-welcome-to-xampp-setup-wizard.png)

Click the forward button to get started with the setup.

### Step 3\. Working with XAMPP setup wizard

The next page is to select components; by default, both options will be checked. Let them as it is and click on the forward button:

![2. select components](https://itsfoss.com/content/images/wordpress/2022/11/2.-select-components.png)

Next, it will tell you that the **XAMPP will be installed in to /opt/lampp directory**:

![3. xampp will be installed at lampp](https://itsfoss.com/content/images/wordpress/2022/11/3.-xampp-will-be-installed-at-lampp.png)

And in the next step, the setup wizard will notify you that the setup is ready and now you can start the installation process:

![4. ready to install](https://itsfoss.com/content/images/wordpress/2022/11/4.-ready-to-install.png)

![5. unpacking and installing files](https://itsfoss.com/content/images/wordpress/2022/11/5.-unpacking-and-installing-files.png)

Once done, you can launch the XAMPP:

![7. xampp in ubuntu](https://itsfoss.com/content/images/wordpress/2022/11/7.-xampp-in-ubuntu.png)

Similarly, you can also use the following command to open XAMPP:

```
sudo /opt/lampp/./manager-linux-x64.run
```

### Step 4\. Create XAMPP desktop shortcut

First, change your working directory to `/usr/share/applications` using the given command:

```
cd /usr/share/applications
```

Here, you will have to create a desktop file with `.desktop` extension. Here, I’m going with `xampp.desktop`:

```
sudo nano xampp.desktop
```

And paste the following lines in `xampp.desktop` file:

```
[Desktop Entry]
Version=1.0
Type=Application
Name=XAMPP Control Panel
Exec=sudo /opt/lampp/manager-linux-x64.run
Icon=/opt/lampp/htdocs/favicon.ico
Terminal=false
StartupNotify=false
```

![create xampp desktop](https://itsfoss.com/content/images/wordpress/2022/11/create-xampp-desktop-1.png)

But XAMPP requires superuser privileges and I have used `Terminal=false` line so how you are supposed to enter the password?

Well, you don’t have to. I will show you a workaround so that it won’t ask for a password. First, open the sudoers file using the given command:

```
sudo visudo
```

And if you are using nano, press Alt + / to jump to the end of the text file. And add the following line, so you can skip entering the password:

```
username ALL = NOPASSWD: /opt/lampp/manager-linux-x64.run
```

Make sure to add your actual username instead of pasting the username. For reference, my username is `sagar` so my line would look like this:

![open xampp without entering password in ubuntu](https://itsfoss.com/content/images/wordpress/2022/11/open-xampp-without-entering-password-in-ubuntu.png)

Save the changes, and you can open XAMPP from your system menu:

![access xampp control panel from system menu in ubuntu](https://itsfoss.com/content/images/wordpress/2022/11/access-xampp-control-panel-from-system-menu-in-ubuntu.png)

### Step 5\. Start MySQL and Apache server

Open the XAMPP control center from your system menu and click on the second tab named `Manage Servers`:

![manage servers in xampp](https://itsfoss.com/content/images/wordpress/2022/11/manage-servers-in-xampp.png)

From here, you can start each one of them individually, or you can use `Start All` button, and it will start all three services at once:

![start apache and mysql database in xampp](https://itsfoss.com/content/images/wordpress/2022/11/start-apache-and-mysql-database-in-xampp.png)

Once started, you can open any of the preferred browsers and type `localhost` in the search bar and if everything is done correctly, it will greet you with a welcome message:

![open myphp admin with xampp](https://itsfoss.com/content/images/wordpress/2022/11/open-myphp-admin-with-xampp.png)

And if you are wondering about the dark mode I got in the locally hosted site, I’m using a plugin named Dark Reader. To learn more, check out the list of [interesting Firefox Add-ons to improve your browsing experience](https://itsfoss.com/firefox-add-ons/).

## Host websites locally using XAMPP

Start the Apache web server from the XAMPP control panel and use the given command to change the current working directory to `/opt/lampp/htdocs/`:

```
cd /opt/lampp/htdocs/
```

Now, create a directory with any name your heart desires. I’m going with `Mysite`:

```
sudo mkdir Mysite
```

Next, I will change the ownership of the directory (mine is named as `Mysite`)from the root to the user, so the directory can easily be accessed without superuser privileges:

```
sudo chown -R $USER:$USER Mysite/
```

Now, change your current directory to the recently created one:

```
cd Mysite
```

And create an index PHP file:

```
touch index.php
```

From here, you can use any of your preferred text editors, but for the sake of this guide, I’m going with VSCode. If you don’t have one, we have a detailed guide on [how you can install VSCode in Ubuntu](https://itsfoss.com/install-visual-studio-code-ubuntu/):

```
code index.php
```

![create and host website locally using xampp in ubuntu](https://itsfoss.com/content/images/wordpress/2022/11/create-and-host-website-locally-using-xampp-in-ubuntu.png)

From here, it’s all up to your creative skills. But for the sake of this guide, I’m only going to make my site print hello world (don’t judge me):

```
<?php
    echo "Hello folks, I hope XAMPP is working fine!"
 ?>
```

![create php website and host locally using xampp](https://itsfoss.com/content/images/wordpress/2022/11/create-php-website-and-host-locally-using-xampp.png)

Save the changes using `Ctrl + S` and now you can access your site from your browser:

```
http://localhost/site-name
```

For me, It was `Mysite` so I’m required to use the following:

```
http://localhost/Mysite
```

![host website locally using xampp in ubuntu](https://itsfoss.com/content/images/wordpress/2022/11/host-website-locally-using-xampp-in-ubuntu.png)

And here you have it. A site hosted on your local network!

## Uninstall XAMPP from Ubuntu

The good news is XAMPP already has the uninstallation script, which saves you the trouble of removing every package manually.

Open your terminal and use the given command to invoke the uninstallation script:

```
sudo /opt/lampp/./uninstall
```

And it will ask you whether you want to remove XAMPP and all of its modules or not:

![do you want to uninstall xampp and all of its modules](https://itsfoss.com/content/images/wordpress/2022/11/do-you-want-to-uninstall-xampp-and-all-of-its-modules.png)

Click on the Yes button, and it will start the uninstallation process:

![uninstalling xampp](https://itsfoss.com/content/images/wordpress/2022/11/uninstalling-xampp.png)

Similarly, you have to use the given commands to remove desktop shortcuts:

```
sudo rm /usr/share/applications/xampp.desktop
```

And that’s it. You have removed XAMPP from your system successfully!

## Wrapping Up

In this tutorial, I installed XAMPP and hosted a PHP website using a local webserver.

While I have tried my best to keep this guide to the beginner’s level, if you have any queries or any issues with installation, setup, or removal, feel free to ask me in the comments.