OutrageousCoder
OutrageousCoder

Reputation: 41

How do I find the document root in Homebrew Apache on MacOS-Mojave?

Mac OS X Mojave.

I am following the instructions at https://www.dionysopoulos.me/custom-apache-and-php-server-on-macos-the-definitive-2019-edition/

Reached the point right before "Install MySQL".

The localhost works with the Apache default file saying "It Works!".

I tried to change the index.html file to add an asterisk (before "It"). Still serving the default.

I tried http://localhost/?2 to force no cache. Still serving default.

I changed the httpd.conf back to the original location /usr/local/var/www and placed the altered index.html file there. Still failure.

I also tried altering the /usr/local/Cellar/httpd/2.4.41_1/.bottle/var/www/index.html Still serving the default.

How do I find out where Apache is really serving from?

Upvotes: 4

Views: 4367

Answers (1)

Cyclonecode
Cyclonecode

Reputation: 30071

Make sure so you actually are changing the correct files for your installation. You can check the current configuration like this:

brew info httpd

The above should give you the path to the installed formula and also should show you the DocumentRoot, for instance in my case:

httpd: stable 2.4.46 (bottled)
Apache HTTP server
https://httpd.apache.org/
/usr/local/Cellar/httpd/2.4.46_2 (1,657 files, 31.4MB) *
Poured from bottle on 2021-02-12 at 06:57:59
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/httpd.rb
License: Apache-2.0
==> Dependencies
Required: apr ✔, apr-util ✔, brotli ✔, nghttp2 ✔, [email protected] ✔, pcre ✔
==> Caveats
DocumentRoot is /usr/local/var/www.

If the above does not work you can also use the apachectl in the httpd package to get the DocumentRoot:

cd `brew --prefix httpd`/bin
apachectl -D DUMP_RUN_CFG

Which would give you something like this:

ServerRoot: "/usr/local/opt/httpd"
Main DocumentRoot: "/usr/local/var/www"
Main ErrorLog: "/usr/local/var/log/httpd/error_log"
Mutex rewrite-map: using_defaults
Mutex default: dir="/usr/local/var/run/httpd/" mechanism=default
Mutex mpm-accept: using_defaults
PidFile: "/usr/local/var/run/httpd/httpd.pid"
Define: DUMP_RUN_CFG
User: name="_www" id=70 not_used
Group: name="_www" id=70 not_used

You can also display your current virtual host configuration using:

apachectl -D DUMP_VHOSTS

Upvotes: 2

Related Questions