Conflict between internal Apache and Apache installed via Homebrew

I have faced following trouble. I wanted to have multiple versions of PHP so I used this article to achieve this. But I could not stop Apache via sudo apachectl -k stop when running this command I am getting the following result: enter image description here

So now it seems like I have two configuration paths:

  • open -e /usr/local/etc/httpd/httpd.conf

  • open -e /etc/apache2/httpd.conf

And currently I am frustrated and stand with following questions: - which path is correct? - why any changes in both files do not change anything? (after loading php7 module instead of php5 doesn't impact after I ran sudo apachectl restart) - how should I cope with this and resolve servers conflict?

Can somebody please help me to resolve this?

P.S. If any additional details are needed or I missed something please let me know in comments.


I had the same problem on a Sierra system. I run:

which -a apachectl

outputted:

/usr/sbin/apachectl
/usr/local/bin/apachectl

to stop the apache by apple version: sudo /usr/sbin/apachectl stop

To see the running processes: ps aux | grep httpd Outputted:

ibook             1359   0,0  0,0  2432804    768 s000  S+    4:13pm   0:00.00 grep httpd
_www              1014   0,0  0,0  2479412    836   ??  S     3:57pm   0:00.00 

/usr/sbin/httpd -k restart
root              1013   0,0  0,1  2479668   7544   ??  Ss    3:57pm   0:00.12 /usr/sbin/httpd -k restart

So to stop apache by apple: sudo /usr/sbin/httpd -k stop And to check if it occurred: ps aux | grep httpd Outputted:

ibok             1375   0,0  0,0  2432804    776 s000  S+    4:14pm   0:00.00 grep httpd

To start the brew apache:

sudo /usr/local/bin/apachectl start

And to check if it's on: ps aux | grep httpd outputted:

 ibook             1390   0,0  0,0  2432804    768 s000  S+    4:14pm   0:00.00 grep httpd
    _www              1387   0,0  0,0  2652596    780   ??  S     4:14pm   0:00.00 /usr/local/opt/httpd/bin/httpd -k start
    _www              1386   0,0  0,0  2652596    752   ??  S     4:14pm   0:00.00 /usr/local/opt/httpd/bin/httpd -k start
    _www              1385   0,0  0,0  2652596    756   ??  S     4:14pm   0:00.00 /usr/local/opt/httpd/bin/httpd -k start
    _www              1384   0,0  0,0  2652596    756   ??  S     4:14pm   0:00.00 /usr/local/opt/httpd/bin/httpd -k start
    _www              1383   0,0  0,0  2652596    744   ??  S     4:14pm   0:00.00 /usr/local/opt/httpd/bin/httpd -k start
    root              1382   0,0  0,1  2652596  10976   ??  Ss    4:14pm   0:00.03 /usr/local/opt/httpd/bin/httpd -k start

To see the running version of apache: httpd -V that outputted:

Server version: Apache/2.4.28 (Unix)
Server built:   Oct 29 2017 19:28:54
Server's Module Magic Number: 20120211:68
Server loaded:  APR 1.5.2, APR-UTIL 1.5.4
Compiled using: APR 1.5.2, APR-UTIL 1.5.4
Architecture:   64-bit
Server MPM:     prefork
  threaded:     no
    forked:     yes (variable process count)
Server compiled with....
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_FLOCK_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=256
 -D HTTPD_ROOT="/usr"
 -D SUEXEC_BIN="/usr/bin/suexec"
 -D DEFAULT_PIDLOG="/private/var/run/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="/private/etc/apache2/mime.types"
 -D SERVER_CONFIG_FILE="/private/etc/apache2/httpd.conf"

And that was the APPLE installed version (2.4.28) again! In stead of the brew 2.4.38. I recognize the frustration.

But it turns out that the pages in the localhost url are served by the new apache!

To show the OSX apache version:

Terminal input: /usr/sbin/apachectl -v

Server version: Apache/2.4.28 (Unix) Server built: Oct 29 2017 19:28:54

And to see the brew version:

Terminal input: /usr/local/bin/apachectl -v

Server version: Apache/2.4.38 (Unix) Server built: Feb 10 2019 02:49:25

And for php: Just type in terminal : which -a php My mac shows:

/usr/bin/php

/usr/local/bin/php

And to show the php versions just use this:

Terminal input: /usr/bin/php -v

shows the OSX build in version: PHP 5.6.30 (cli) (built: Oct 29 2017 20:30:32) Copyright © 1997-2016 The PHP Group Zend Engine v2.6.0, Copyright © 1998-2016 Zend Technologies

And terminal input: /usr/local/bin/php -v

Will show the brew version: PHP 7.3.2 (cli) (built: Feb 14 2019 10:09:47) ( NTS ) Copyright © 1997-2018 The PHP Group Zend Engine v3.3.2, Copyright © 1998-2018 Zend Technologies with Zend OPcache v7.3.2, Copyright © 1999-2018, by Zend Technologies


I think default apache path

/etc/apache2/httpd.conf

and homebrew apache path

/usr/local/etc/httpd/httpd.conf

And you may have 2 apache in your system use this cmd to check

which -a apachectl

apache for default

/usr/sbin/apachectl 

apache for homebrew. I think so.

/usr/local/bin/apachectl

The command below use for default apache. I think.

sudo apachectl restart

You may use this

sudo /usr/local/bin/apachectl restart