After starting using XAMPP in Ubuntu, there's a common error appeared to the users. That is considered as the failure of starting of Apache web server. We have to stop it and restart it. 

Stop Code - sudo /etc/init.d/apache2 stop
Start Code - sudo /opt/lampp/lampp start 

And the other problem is we have to start the server using a terminal command, whenever we want to use it. Here I'm going to explain a way to get rid of these two problems. If you can make XAMPP to start automatically when you reboot the machine, there you find  the  solution. This is the way to to it. 

1. First, open a terminal and type this command to edit the lampp file located in etc folder. 

       sudo gedit /etc/init.d/lampp

2. A text file will be  opened and type the following commands to add the script to make XAMPP to       be started automatically.

#!/bin/bash
### BEGIN INIT INFO
# Provides: lampp
# Required-Start:    $local_fs $syslog $remote_fs dbus
# Required-Stop:     $local_fs $syslog $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start lampp
### END INIT INFO
/opt/lampp/lampp start

3. Save this file and close the file. If terminal is still running, press ctrl + c to terminate it.
    Then type this command.

    sudo chmod +x /etc/init.d/lampp

4. Finally type this command also to update the relevant file.

    sudo update-rc.d lampp defaults

5. Now restart the machine!

Open the XAMPP GUI or type sudo /opt/lampp/lampp start on a  terminal to check whether XAMPP is running or not. There you will see all 3 services are running in the system. That's all....!

Enjoy the power of XAMPP!

3 Comments

  1. It does not work for me. With or without # from the main body. Tell me what I had done wrong, please
    !/bin/bash
    ### BEGIN INIT INFO
    Provides: lampp
    Required-Start: $local_fs $syslog $remote_fs dbus
    Required-Stop: $local_fs $syslog $remote_fs
    Default-Start: 2 3 4 5
    Default-Stop: 0 1 6
    Short-Description: Start lampp
    ### END INIT INFO
    /opt/lampp/lampp start

    ReplyDelete
  2. thats right it does not work. use the steps below instead :


    There is no real standard way to configure the boot process of a Linux system, but most of them should allow you to start XAMPP at boot time using the following steps.

    Debian, Ubuntu.

    sudo ln -s /opt/lampp/lampp /etc/init.d/lampp

    sudo update-rc.d lampp start 80 2 3 4 5 . stop 30 0 1 6 .

    RedHat, Fedora, CentOS. If your Linux distro uses "chkconfig" tool to install the services you can run the following commands:

    sudo ln -s /opt/lampp/lampp /etc/init.d/lampp

    sudo chkconfig --add lampp

    SUSE

    sudo ln -s /opt/lampp/lampp /etc/init.d/lampp

    sudo chkconfig lampp 2345

    ReplyDelete
  3. Works perfectly on Ubuntu 20.04.3 LTS, thank you very much.

    ReplyDelete