mike.void
mike.void

Reputation: 192

Can't change document root for apache 2.4

I want to set up local web server using Apache and PHP on my Mac running Sierra. I followed this tutorial:

https://getgrav.org/blog/macos-sierra-apache-multiple-php-versions

And I am stuck at changing the document root from httpd.config, for whatever reason this change does not take effect at all. If I type http://localhost it still says "It works", it still uses the original html file.

Another weird thing is that apparently I can't stop apache at all. I tried running

$ sudo apachectl stop

but I still can’t access http://localhost

if I run

$ brew services list

httpd24 is stopped. What gives? What am I doing wrong?

Upvotes: 1

Views: 888

Answers (1)

Ortomala Lokni
Ortomala Lokni

Reputation: 62625

There is an instance of apache pre-installed with macOS. So you have now two versions of apache installed. If you check:

which  apachectl

you will probably obtain:

/usr/sbin/apachectl

which is the official macOS version of apachectl. Stop it with:

sudo apachectl stop

Disable the auto-loading of the pre-installed apache with (as explained in the tutorial you mentioned):

sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null

To run the homebrew version do:

brew services run httpd24

to stop it:

brew services stop httpd24

to register it to launch at login:

brew services start httpd24

Upvotes: 2

Related Questions