April 4th, 2007 ··· andarius
I needed a way to start httpd (apache) and mysqld (MySQL) easily and I did not want them running all the time. I use them on my desktop and laptop for web development and testing. Since I don’t work on web stuff all the time it would be senseless to run them all the time. It was just easiest to create a start-stop script to use when I needed it.
You can copy what follows to a file, chmod +x it and run it with start, stop or restart for the desired actions.
#!/bin/sh
#
# webservices
#
# Starts or stops services for web hosting, or in this case
# mysqld and httpd (apache ). This script keeps one from
# having to manualy do these things and from having them
# run all the time.
#
# It calls to the Slackware start up scripts in part to keep
# things clean and simple.
# Start things up:
ws_start() {
sh /etc/rc.d/rc.mysqld start > /dev/null 2>&1 && echo "mysqld started"
/usr/sbin/apachectl start > /dev/null 2>&1 && echo "httpd started"
}
# Stop things:
ws_stop() {
sh /etc/rc.d/rc.mysqld stop > /dev/null 2>&1 && echo "mysqld stopped"
/usr/sbin/apachectl stop > /dev/null 2>&1 && echo "httpd stopped"
}
# Restart them:
ws_restart() {
ws_stop
ws_start
}
# Find out what we want to do:
case "$1" in
'start')
ws_start ;;
'stop')
ws_stop ;;
'restart')
ws_restart ;;
*)
echo "usage $0 start|stop|restart"
esac
Leave a Reply







