Original post on my tumblr.
$ pgrep apache2 | wc -l
pgrep will search processes just like "grep". Above, I am searching for processes which match "apache2". You may want to search for "http" or "httpd" if apache2 isn't what your Apache processes is called.
wc -l WC will print newline, word or byte counts for a file or piped in content. The -l flag specifically prints the newline count.
Combined, this command will list the number of apache2 processes currently running.