How to Install XAMPP in Linux

XAMPP is a popular open-source software stack that provides developers with a convenient solution for setting up a local web server environment. In this blog post, I’ll guide you through the process of installing XAMPP on a Linux system. This will enable you to create a development and testing environment for your web projects.

Step 1: Download XAMPP

Before we begin, make sure to download the XAMPP installer file from the official website. Once downloaded, navigate to the ~/Downloads/ or your downloaded directory using the following command:

cd ~/Downloads/

Step 2: Making XAMPP Installer Executable

To proceed with the installation, it is necessary to make the XAMPP installer file executable. Run the following command to change the file’s execution bits:

sudo chmod 755

Step 3: Running the XAMPP Installer

Execute the XAMPP installer file using the following command:

sudo ./

Step 4: Starting XAMPP

Once the installation is complete, you can start XAMPP by running the command:

sudo /opt/lampp/lampp start

Step 5: Securing XAMPP

To secure XAMPP and restrict access to Apache, MySQL, and ProFTPD, follow the steps below:

Making Apache Listen to Localhost:

  • Open the Apache configuration file using the command:
sudo nano /opt/lampp/etc/httpd.conf
  • Locate the line that says “Listen 80” and replace it with:
  • Save the changes and exit the editor.

Disabling Apache Listening on Port 443:

  • Open the SSL configuration file using the command:
sudo nano /opt/lampp/etc/extra/httpd-ssl.conf

Comment out the line that says “Listen 443” by adding a hash symbol (#) in front of it.

Restricting MySQL Access to Localhost:

  • Open the MySQL configuration file using the command:
sudo nano /opt/lampp/etc/my.cnf
  • Add the following line after the line “[mysqld]“:
  • Save the changes and exit the editor.

Restricting ProFTPD Access to Localhost:

  • Open the ProFTPD configuration file using the command:
sudo nano /opt/lampp/etc/proftpd.conf
  • Add the following two lines after the line “DefaultServer on“:
SocketBindTight on
  • Save the changes and exit the editor.

However, there is a limitation to consider with the XAMPP install. It only allows the creation of a localhost that points to a single folder. This can become problematic if you are working with a content management system (CMS) like WordPress and need to create multiple installations within different folders.

To address this issue, the next step will be useful. The idea is to create a symbolic link that provides a solution for organizing and accessing multiple installations easily.

Step 6: Creating Symbolic Link

To easily access your project files, you can create a symbolic link. Use the following command, replacing the directory path with your own:

sudo ln -s /media/work/lamp/ /opt/lampt/htdocs/$USER

This command utilizes the ln command with the -s option to create a symbolic link. Symbolic links work similarly to shortcuts or aliases in Linux or Windows systems, enabling you to access files or directories from one location to another.

When you execute this command, it creates a symbolic link named “lamp” in the /opt/lampt/htdocs/ directory. This link points to the /media/work/lamp/ directory or file.

As a result, it becomes much more convenient to access the files within the /media/work/lamp/ directory from the web server directory specified as /opt/lampt/htdocs/. This allows for efficient management and access of multiple CMS installations or projects.

Step 7: Modifying httpd.conf File

When creating symbolic links as mentioned earlier, you may encounter a 403 error if you try to access the PHP files or folders located inside the /media/work/lamp directory. To resolve this issue, you can make modifications to the httpd.conf file, which is located at /opt/lampp/etc/httpd.conf.

To make the necessary adjustments, you can use your preferred text editor to open the httpd.conf file and append the following lines to the end:

Alias /bitnami/ "/opt/lampp/apache2/htdocs/"
Alias /bitnami "/opt/lampp/apache2/htdocs"

<Directory "/opt/lampp/apache2/htdocs">
  Options Indexes FollowSymLinks ExecCGI Includes
  AllowOverride All
  Require all granted

<Directory />
    AllowOverride All
    Require all granted

User username
Group username

Finally, the User username and Group username lines specify the user and group under which Apache runs, so modify it according to your username.

These configuration steps modify the “httpd.conf” file in XAMPP to make certain adjustments and define access permissions for the server.

By following the steps outlined in this blog post, you can successfully install XAMPP in Linux and ensure its security. Restricting access to Apache, MySQL, and ProFTPD to localhost minimizes the potential risks associated with running a web server.

The steps outlined above represent my personal workflow for configuring and working with XAMPP in a closed environment. Feel free to modify them based on your specific requirements. The purpose of providing these steps is to serve as a reference guide. Enjoy developing and testing your web applications with XAMPP!

In addition to the previous resources, you may find my other blog posts on how to run WP CLI and Composer in XAMPP helpful. Please feel free to explore those articles for detailed instructions and insights.