Right. Assuming you are running a RedHat-based Linux machine:
1.) Go to /etc/rc.d/init.d (or just /etc/init.d, same thing, it's a link to rc.d/init.d)
2.) Paste your script there. A sample script would be:
Code:
#!/bin/bash
#
# Run-level Startup script for XAMPP
#
# chkconfig: 0123456 91 19
# description: Startup/Shutdown service for XAMPP
case "$1" in
start)
echo "Starting XAMPP: "
/opt/lampp/lampp start
;;
stop)
echo "Shutdown XAMPP: "
/opt/lampp/lampp stop
;;
restart)
echo "Restarting XAMPP: "
/opt/lampp/lampp restart
;;
*)
echo "XAMPP Startup/Shutdown Service"
echo "Scripted by JV Roig"
echo ""
echo "XAMPP is an easy-to-use implementation of:"
echo " -Apache webserver with SSL support"
echo " -PHP (versions 4 and 5)"
echo " -MySQL Database Server"
echo " -ProFTPD and a lot of others"
echo ""
echo "Usage: "
echo "service xampp start - starts the XAMPP service."
echo "service xampp stop - stops the XAMPP service."
echo "service xampp restart - restarts the XAMPP service."
echo ""
exit 1
esac
exit 0
That's pretty basic right there. The app name in this case is "xampp" (it's a pretty redundant app when you think of it, since in modern linux distros you arleady get httpd, mysqld in the package manager, along with vsftpd... but this is ok as an example, and the only one I could get from my archive quickly, back in the days when I had to use xampp by ApacheFriends. Also, I should add that xampp is actually pretty convenient for devs who don't want to go to the hassle of configuring all the components by themselves, but as noted, modern linux distros make it almost painless already)
If you are familiar with bash scripting, then that's a wrap.
3. (Optional) If you also want your service to run automatically depending on the runlevel, you use chkconfig command after you paste your script. Assuming "xampp" is the name of your script:
Code:
chkconfig --add xampp
chkconfig --level 0123456 off
chkconfig --level 345 on
That makes it start automatically when you boot up in either in command line mode or the normal GUI mode, and the service is stopped properly when you restart or shut down. Technically, you don't really need to "chkconfig --level 0123456 off", because runlevels will be off by default, but that's just being thorough and it's just one line
Regards.