megclaypool
2/15/2019 - 6:51 PM

Working with httpd / apachectl on Mac

Check if apache is running:

There are a couple of different ways.

netstat -at | grep LISTEN | grep *.http

You should see something like:

10:54:12  ~/Sites/
 => netstat -at | grep LISTEN | grep *.http
tcp46      0      0  *.http                 *.*                    LISTEN  

If there are no results, apache isn't running.

ps aux | grep httpd

You should see something like:

 10:45:57  ~/Sites/  
 => ps aux | grep httpd
noxlady           2795   0.0  0.0  4278260    816 s005  S+   10:46AM   0:00.00 grep httpd
noxlady           2775   0.0  0.0  4549224   1148   ??  S    10:45AM   0:00.00 /usr/local/opt/httpd/bin/httpd -k start
noxlady           2774   0.0  0.0  4549224   1168   ??  S    10:45AM   0:00.00 /usr/local/opt/httpd/bin/httpd -k start
noxlady           2773   0.0  0.0  4549224   1184   ??  S    10:45AM   0:00.00 /usr/local/opt/httpd/bin/httpd -k start
noxlady           2772   0.0  0.0  4549224   1196   ??  S    10:45AM   0:00.00 /usr/local/opt/httpd/bin/httpd -k start
noxlady           2771   0.0  0.0  4549224   1184   ??  S    10:45AM   0:00.00 /usr/local/opt/httpd/bin/httpd -k start
root              2760   0.0  0.2  4549248  26528   ??  Ss   10:45AM   0:00.04 /usr/local/opt/httpd/bin/httpd -k start

If all you see is:

10:45:40  ~/Sites/
 => ps aux | grep httpd
noxlady           2728   0.0  0.0  4277236    800 s005  S+   10:45AM   0:00.00 grep httpd

then apache isn't running (it's just finding the search you just ran).

Start apache

sudo apachectl start (Oddly, this seems to work when restart doesn't...)

Restart apache

sudo apachectl -k restart

Stop apache

sudo apachectl -k stop

Check the Apache Configuration for Errors

apachectl configtest