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 

apt-get install gedit

Prerequisites

There are two prerequisites for the script.

  1. A functional XAMPP installation
  2. 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 

verify installation

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 

open script file

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 

script to autostart

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 

enabling script

Verifying the script

This script automatically starts XAMPP when we start the system. To verify it, restart the system.

 $sudo reboot -f 

reboot -f

After the system reboots, you can open a web browser and access the following URL to verify the running XAMPP.

http://localhost/

verify 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.

ComputerNetworkingNotes Linux Tutorials Auto Start XAMPP at Startup in Ubuntu Linux

We do not accept any kind of Guest Post. Except Guest post submission, for any other query (such as adverting opportunity, product advertisement, feedback, suggestion, error reporting and technical issue) or simply just say to hello mail us [email protected]