Is Apache running?
Solution 1
Is it running?
pgrep apache
Any output is good, nothing means it isn't running.
What version:
aptitude show apache2
Solution 2
Have you tried talking to it?
telnet localhost 80
HEAD / HTTP/1.0
<extra carriage return>
Solution 3
To check for Apache 1.X see below, for Apache 2.X see wzzrd's answer.
The apache web server process is called httpd so a quick way to start with confirming apache is installed and running is:
ps -A | grep 'httpd'
ps -A lists all the running processes grep 'httpd' filters only lines containing 'httpd'
If you don't get any results, apache is not running.
regarding version, try:
apachectl status
in the output there should be a line like:
Apache/1.3.41 Server at www.xyz.com Port 80
If it cannot find apachectl, it may not be in your execution path, try:
whereis apachectl
to see where it is located
These are distribution agnostic ways so no matter how apache was installed on the system, you should find it with these.
Solution 4
Click here: http://localhost If you don't get an error 404, it's running.
Iain Samuel McLean Elder
"The truth, the whole truth, and nothing but the truth, so help me, Codd." Find me on: LinkedIn (isme.es/linkedin) BitBucket (isme.es/bitbucket) Github (isme.es/github)
Updated on September 17, 2022Comments
-
Iain Samuel McLean Elder over 1 year
I've just taken over webmastery for my company's site, and I'm preparing a report for my partner about the LAMP stack. But I'm a new CS graduate, and the only thing I know really well is Java coding, so I need some help!
I'm trying to find out a) if Apache is installed and b) what version is running.
My Linux version is "Ubuntu 8.04.4 LTS \n \l", as reported by
/etc/issue
. -
Iain Samuel McLean Elder over 13 years"ps -A | grep 'httpd'" produces no output.
-
Iain Samuel McLean Elder over 13 years"apachectl status" produces "-bash: apachectl: command not found"
-
Iain Samuel McLean Elder over 13 years"whereis apachectl" produces "apachectl:"
-
Iain Samuel McLean Elder over 13 years
telnet localhost 80
produces-bash: telnet: command not found
-
Iain Samuel McLean Elder over 13 years
/sbin/service httpd status
produces-bash: /sbin/service: No such file or directory
-
Iain Samuel McLean Elder over 13 yearsHowever,
ps -A | grep apache2
produces ` 2691 ? 00:00:01 apache2` and 10 otherapache2
processes. -
Iain Samuel McLean Elder over 13 years
pgrep apache
produces 11 lines of output. -
Iain Samuel McLean Elder over 13 years
aptitude show apache2
produces lots of output, including the lineVersion: 2.2.8-1ubuntu0.15
. -
Iain Samuel McLean Elder over 13 yearsMy server instance is a VPS, so I can't just click a link on my local machine to check whether it's running.
-
Iain Samuel McLean Elder over 13 yearsI appreciate the amount of effort you put into your answer, but I have to mark you down because these are not "distribution agnostic" ways to determinte how apache was installed. Apparently on Ubuntu the process is called
apache2
. See wzzrd's answer: serverfault.com/questions/177915/is-apache-running/… -
halp over 13 yearsYou could run some ncurses web browser like links or lynx directly on the server.
-
Marc B over 13 years
apache2 -version
in a shell would also work. -
ManiacZX over 13 years@isme, actually, that isn't a distribution issue but an apache major version issue. I was referencing a box with apache 1.x on it. The instructions would have worked on Ubuntu with apache 1.x and the other answer would have not produced a result.
-
Denys over 13 yearsYou should consider installing it or something with similar functionality such as ncat (part of nmap 5). Talking directly to your web (or SMTP or POP or IMAP or SIP or FTP or …) server can be indispensable for troubleshooting.