Auto start xampp in ubuntu 16.04

22,640

Solution 1

    • First move that particular script to /etc/init.d/ Directory

for example

#! /bin/sh
# /etc/init.d/lampp
#

# Some things that run always
touch /var/lock/lampp

# Carry out specific functions when asked to by the system
case "$1" in
  start)
    echo "Starting script lampp "
    echo "Could do more here"
    ;;
  stop)
    echo "Stopping script lampp"
    echo "Could do more here"
    ;;
  *)
    echo "Usage: /etc/init.d/lampp {start|stop}"
    exit 1
    ;;
esac

exit 0

Once you've saved your file into the correct location make sure that it's executable by running "chmod 755 /etc/init.d/lampp".

Then you need to add the appropriate symbolic links to cause the script to be executed when the system goes down, or comes up.

*it's this way

root@root:~# update-rc.d lampp defaults

2.Do it using GUI

  • STARTUP APPLICATIONenter image description here

Solution 2

My solution is rather simple.

Simply open terminal and write

sudo gedit /etc/rc.local

And then add these 2 lines just before the last line

cd /opt/lampp/
sudo ./lampp start

And that's it. Simply save and restart the computer. Please note that these lines should be above the last line that says exit 0

I hope it helps someone else.

Solution 3

Thank you for the answer which has helped me, Akhil Varma.

Based on the earlier from Akhil Varma, I would like to share a modified version for /etc/init.d/lampp to support service or systemctl command fully. Please make sure the command used and file created is done in root.

#! /bin/sh
# /etc/init.d/lampp
#

# Some things that run always touch /var/lock/lampp

# Carry out specific functions when asked to by the system case "$1" in   start)
    echo "Starting script lampp "
    /opt/lampp/lampp start
    /opt/lampp/lampp startftp
    ;;   status)
    echo "Status of script lampp"
    /opt/lampp/lampp status
    if test -f /opt/lampp/logs/httpd.pid 
    then
      exit 0
    else
      exit 3
    fi
    ;;   stop)
    echo "Stopping script lampp"
    /opt/lampp/lampp stop
    ;;   *)
    echo "Usage: /etc/init.d/lampp {start|stop|status}"
    exit 1
    ;; esac

exit 0

This is assuming the installation directory for LAMPP/XAMPP is at /opt/lampp. Change accordingly if your LAMPP/XAMPP installation directory is different.

Make sure the /etc/init.d/lampp is executable by:

chmod 755 /etc/init.d/lampp

To enable auto-start for LAMPP/XAMPP service:

update-rc.d lampp defaults

You can now use the following service command as follows, and it will report correctly:

service lampp status
service --status-all

or

systemctl status lampp

To start/stop the lampp manually:

service lampp start
service lampp stop

or

systemctl start lampp
systemctl stop lampp

Hope it helps.

Share:
22,640

Related videos on Youtube

Adarsh Hiwrale
Author by

Adarsh Hiwrale

Updated on September 18, 2022

Comments

  • Adarsh Hiwrale
    Adarsh Hiwrale over 1 year

    Every time I start or restart my Ubuntu 16, Xampp doesn't start I have start manually by sudo /opt/lampp/lampp start. Making script like sudo nano /etc/init.d/lampp doesn't work command update-rc.d lampp defaults gives me error:

    insserv: warning: script 'K01lampp' missing LSB tags and overrides
    insserv: warning: script 'lampp' missing LSB tags and overrides
    insserv: fopen(.depend.stop): Permission denied
    

    The script File contains the below lines:

    [#!/bin/bash
    
    /opt/lampp/lampp start]
    

    Any solution?

  • Adarsh Hiwrale
    Adarsh Hiwrale over 7 years
    I tried making a symbolic link but gives me error: ln: failed to create symbolic link '/opt/lampp/lampp': File exists
  • Adarsh Hiwrale
    Adarsh Hiwrale over 7 years
    The file which i have made is in /etc/init.d/lampp and the original file is in /opt/lampp/lampp .
  • Adarsh Hiwrale
    Adarsh Hiwrale over 7 years
    /opt/lampp/lampp this the main file which i use to start xampp sudo /opt/lampp/lampp start
  • Muhammad bin Yusrat
    Muhammad bin Yusrat about 7 years
    Try my answer below. That should be much more easy.
  • Lye Heng Foo
    Lye Heng Foo over 4 years
    Thank you for the answer which has helped me, Akhil Varma. I have expanded your script a bit more to fully support the service command fully. Please refer to my answer below for my sharing. Thank you.