Starting and Stopping Development Server on Laptop

Published on

I am not sure how much battery life suffers on my laptop when it is unnecessarily running Apache, PostgreSQL and MySQL, but the databases consistently show up in the list when I use PowerTop, so it is probably not insignificant. Anyway, since I knew it couldn’t be to hard to shut them down and start them up again when I needed to, I wrote a couple little bash scripts to do the job.

LampStart.sh

  sudo /etc/init.d/mysql start
  sudo service mysql start
  sudo /etc/init.d/postgresql-8.4 start
  sudo /etc/init.d/apache2 start

LampStop.sh

  sudo /etc/init.d/mysql stop
  sudo service mysql stop
  sudo /etc/init.d/postgresql-8.4 stop
  sudo /etc/init.d/apache2 stop

To reuse these you might have to modify them for your particular server setup, but that would be relatively easy. The other thing I did is to make them executable. Then I put them on my desktop and I treat them like simple switches. Click on. Click off. Easy! All this made me think again about the merits of using something like XAMPP for development environments. Not really sure what I would lose or gain by doing that, but one thing I do remember from my Windows days when I used it that it had a control panel with lots of handy on/off/restart switches.

2020 update

Just use docker or some sort of container thing.