While setting up my new VPS to host a Rails application with Apache/Passenger, I noticed an odd discrepancy between servers. Both running Ubuntu with Apache installed via aptitude
, but the older server threw this error:
root@www:/etc/apache2# apache2ctl status
/usr/sbin/apache2ctl: 124: www-browser: not found
Meanwhile, the newer VPS showed the expected server status output. Here's what I discovered about this behavior.
The apache2ctl status
command attempts to display server information in a text-based browser. On line 124 of /usr/sbin/apache2ctl
, you'll find:
www-browser -dump "http://$HOST:$PORT/server-status" 2>/dev/null || \
lynx -dump "http://$HOST:$PORT/server-status" 2>/dev/null || \
links -dump "http://$HOST:$PORT/server-status" 2>/dev/null
The script tries three different text browsers in sequence. The error occurs when none are installed.
Option 1: Install a text browser
The simplest fix is to install one of the supported browsers:
sudo apt-get install w3m # Lightweight option
# OR
sudo apt-get install lynx # More feature-rich
Option 2: Directly query the status URL
For server environments where you don't need the formatted output:
curl http://localhost/server-status?auto
This gives you machine-readable output perfect for monitoring scripts.
The difference between your VPS instances likely comes from:
- Different Ubuntu base images (minimal vs standard)
- Changed package dependencies in newer Apache versions
- Manual installation of text browsers during other setup processes
For production environments, I recommend:
# Install minimal browser
sudo apt-get install w3m
# Then secure your status page by editing apache config:
<Location /server-status>
SetHandler server-status
Require local
# Optional: Add basic auth
AuthType Basic
AuthName "Server Status"
AuthUserFile /etc/apache2/.htpasswd
Require valid-user
</Location>
When running apache2ctl status
on some Ubuntu systems, you might encounter the error:
/usr/sbin/apache2ctl: 124: www-browser: not found
This occurs because the Apache status handler attempts to launch a text-based web browser to display server statistics, but no suitable browser is installed on your system.
The apache2ctl
script contains logic to display status information in a browser when run interactively. On line 124 (in Apache 2.2.x), it tries to execute:
www-browser "http://$SERVER:$PORT/server-status"
Ubuntu systems typically don't ship with www-browser
by default, although some installations may have it as part of the debianutils
package or from other browser installations.
Option 1: Install a Text Browser
The most straightforward solution is to install a text-based web browser:
sudo apt-get install w3m
Alternatively, you could install lynx
or links
:
sudo apt-get install lynx
Option 2: Modify apache2ctl Behavior
If you prefer not to install a browser, you can modify how apache2ctl
handles the status command. Edit the file:
sudo nano /usr/sbin/apache2ctl
Find the line containing www-browser
(around line 124) and change it to:
curl "http://$SERVER:$PORT/server-status"
Or simply comment out the browser invocation entirely if you only need the raw output.
Option 3: Access Status Directly
Instead of using apache2ctl status
, you can query the status page directly:
curl http://localhost/server-status?auto
This gives you machine-readable output that's often more useful for scripting.
For production systems, I recommend:
sudo apt-get install lynx
sudo ln -s /usr/bin/lynx /usr/bin/www-browser
This provides a lightweight solution that maintains compatibility with other system tools that might expect www-browser
to exist.
For serious monitoring, consider parsing the machine-readable output:
#!/bin/bash
STATS=$(curl -s "http://localhost/server-status?auto")
echo "Current connections: $(echo "$STATS" | grep "Total Accesses" | cut -d' ' -f3)"
You can extend this script to monitor critical metrics and alert when thresholds are exceeded.