Auto start xampp in ubuntu 16.04
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
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.
Related videos on Youtube
Adarsh Hiwrale
Updated on September 18, 2022Comments
-
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 likesudo nano /etc/init.d/lampp
doesn't work commandupdate-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 over 7 yearsI tried making a symbolic link but gives me error:
ln: failed to create symbolic link '/opt/lampp/lampp': File exists
-
Adarsh Hiwrale over 7 yearsThe file which i have made is in
/etc/init.d/lampp
and the original file is in/opt/lampp/lampp
. -
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 about 7 yearsTry my answer below. That should be much more easy.
-
Lye Heng Foo over 4 yearsThank 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.