Dev machine LAMP stop start restart

Say you have a debian laptop of limited horsepower. Say that on your laptop you don't want mysql and apache running all the time, so you can set them to only start up when you want them. Say you don't want XAMP or something that installs your services in no standard places that debian won't find them to update them. So write your own script to only start LAMP when you want it running.

First remove apache and mysql tendency to start with the machine:

update-rc.d -f mysql remove
update-rc.d mysql stop 20 2 3 4 5 .

update-rc.d -f apache2 remove
update-rc.d apache2 stop 20 2 3 4 5 .

then create a bash script that will allow you to do:

sudo lamp start
sudo lamp stop
sudo lamp restart

Here's the script:

#!/bin/sh
case "${1:-''}" in
'start')
/etc/init.d/mysql start
/etc/init.d/apache2 start
;;

'stop')
/etc/init.d/mysql stop
/etc/init.d/apache2 stop
;;

'restart')
lamp stop
lamp start
;;
*)
echo "start stop or restart, please"
;;
esac

then mod the script to be executable
chmod o+x lamp.sh

then move or link the script from a directory in your command path
ln -s path/to/lamp.sh /usr/bin/lamp

You're done.