Auto Start XAMPP at Startup in Ubuntu Linux
With the default XAMPP installation, you must start XAMPP manually every time you start the system. If you are a web developer or use XAMPP frequently, it can be frustrating to start it every time. Instead of manually starting it every time, we can create and enable a script that automatically starts it on startup.
Choosing a text editor
You can use any standard text editor such as Vi or Nano to create the script. However, these editors are a bit complex unless you are a system or network administrator. If you generally use any of these editors, you can use it. If not, you can install the gedit editor. The gedit is a simple notepad-like text editor. You can use it to create or update script files.
The following command installs the gedit text editor.
$sudo apt-get install gedit

Prerequisites
There are two prerequisites for the script.
- A functional XAMPP installation
- The net-tools package
The net-tools package includes the commands to start, stop, and restart XAMPP from the command line. Run the following command to verify both.
#sudo /opt/lamp/lamp start
Related Articles
The following tutorial explains how to install XAMPP and net-tools on Ubuntu.
How to install XAMPP on Ubuntu Linux
The following tutorial explains how to fix the XAMPP htdocs folder permission issue on Ubuntu.
How to fix the XAMPP htdocs folder permission issue on Ubuntu
Creating the script
The /etc/systemd/system directory saves script files. The following command creates a script file and opens it for editing.
$sudo gedit /etc/systemd/system/xampp.service
Add the following lines to the file and save it.
[Unit] Description=XAMPP [Service] ExecStart=/opt/lampp/lampp start ExecStop=/opt/lampp/lampp stop Type=forking [Install] WantedBy=multi-user.target
Enabling the script
After creating the script, we must enable it. Ubuntu automatically executes all enabled scripts after the system boots. The following command enables the script.
$sudo systemctl enable xampp.service

Verifying the script
This script automatically starts XAMPP when we start the system. To verify it, restart the system.
$sudo reboot -f
After the system reboots, you can open a web browser and access the following URL to verify the running XAMPP.
http://localhost/

You can also verify it from the command line. The systemctl status command displays the current status of the service.
$sudo systemctl status xampp-service
Conclusion
If you frequently use XAMPP, you can create a script that automatically starts it when you start the system. This tutorial explained how to create, implement, and test this script.
By ComputerNetworkingNotes Updated on 2025-09-06