For Ubuntu:

  • Create a script in init.d called lampp sudo gedit /etc/init.d/lampp
  • Paste this code on the script and save
#!/bin/bash
/opt/lampp/lampp start
  • Give -x permissions to the file sudo chmod +x /etc/init.d/lampp
  • Use update-rc.d to install init scripts to all runlevel by typing sudo update-rc.d lampp defaults

For CentOS:

  • Open /etc/rc.local using command

vi /etc/rc.local

  • Add the following line in at end of the file

/opt/lampp/lampp start