Monday, August 09, 2010

Apachectl: Use Wget instead of Lynx

A common error with apachectl is 'cannot find lynx'. This is a silly error because lynx is a text mode browser that is just used to retrieve the server-status page and grep out pertinent information.

Building Lynx just for use starting, stoppping, restarting, graceful, status, statusfull, etc. on Apache is silly. Most servers already have Curl or Wget. I prefer wget because it's simple and easy to use.

To use wget instead of lynx, modify your apachectl file as follows:

1. add a line near the top with:


2. About line 90-ish, you'll see status) - you should make it look like this:

# $LYNX $STATUSURL | awk ' /process$/ { print; exit } { print } '
/usr/bin/wget $STATUSURL -q -O - | egrep '(Current|Restart|uptime)' | sed 's/<[/]*dt>//g'
if [[ -f $PIDFILE ]] ; then
echo "PID: " `cat $PIDFILE`
echo "No PID file."

This uses wget to grab the status (uptime, restart time, etc.) instead of Lynx, which as I said should be discontinued as a dependency. As you can see, Wget solves the problem easily.

Note that the bottom section for fullstatus) is not changed; I didn't need the fullstatus, if you do, feel free to improve on this text.

Post a Comment