28

Is there any command to find out if apache is running or not.

and on which port except by seeingports.conf files

When i try netstat command then apaches does not appear in that.

but when i use apache2 restart command then it says restart ok

i don't know where it is running

6 Answers6

27
netstat -anp | grep apache

You could see the listening port and PID from this if it's running.

Jeff Atwood
  • 13,104
  • 20
  • 75
  • 92
user40424
  • 316
  • 2
  • 3
25

lsof -i list open ports and the corresponding applications.

For a general check if an app is running you could just use ps aux | grep apache2

Sven
  • 98,649
  • 14
  • 180
  • 226
6
netstat -tulpn

You'll see the Pid / Binary name on far right column, match this to your running apache instance.

Brian Tillman
  • 693
  • 3
  • 5
3

If lsof is installed you could try something like this:

lsof | grep httpd

(for centos and friends)

lsof  | grep apache

(for debian and company)

Jeff Atwood
  • 13,104
  • 20
  • 75
  • 92
1

If you just want the port number then run

sudo netstat -anp | grep apache | awk 'NR==1{print $4}' | grep -Eo '[0-9]{1,4}'
Guess
  • 11
  • 1
0

For FreeBSD:

sockstat | grep apache httpd