Reputation: 4592
My local website access failed after an upgrade to High Sierra as it does after every upgrade. This time I though I was on top of it because I put all my changes into /other/overides.conf. It still didn't work. I was finally able to fix it by removing Listen 80 every where it appeared. This new code came with the latest httpd.conf
<IfDefine SERVER_APP_HAS_DEFAULT_PORTS>
Listen 8080
</IfDefine>
<IfDefine !SERVER_APP_HAS_DEFAULT_PORTS>
Listen 80
</IfDefine>
Obviously the change has to do with a newer version of Apache. What's the reason for the change and did I fix it correctly?
Upvotes: 5
Views: 3294
Reputation: 1229
In previous macOS versions, the section you mention was a single Listen 80
line, in the same place at the start of /etc/apache2/httpd.conf
. Purely for ease of setting things up when you upgrade macOS, this is the right place to put your own Listen
directives. For example, every time I upgrade, I replace that line with
Listen 80
Listen 81
Listen 82
and then reinstate my existing httpd-vhosts.conf
file, where I keep as much as possible of my custom config.
(You imply that you had Listen
directives in lots of places, and I'm not sure why that would be the case. It's more usual to have them all in one place, and certainly easier, especially when you're dealing with Apple's 'Groundhog Day' approach to config files)
I can't find any documentation on the new form, and it's not mentioned anywhere else in the High Sierra config files or in the launchd
invocation for Apache. But what it does is pretty clear: it selects one of two alternate Listen
configurations based on whether a certain parameter is set. The only conceivable reason for this is to allow Apple to switch between two different setups without needing to modify the http.conf
file. I would guess it relates to a checkbox somewhere, perhaps in the Server app (which I don't have installed), or perhaps it anticipates some future option.
In any case, my reasoning is: in the past, I modified what Apache did instead of listening to port 80, so that is the part I should modify now. Therefore I changed my new High Sierra httpd.conf
to:
<IfDefine SERVER_APP_HAS_DEFAULT_PORTS>
Listen 8080
</IfDefine>
<IfDefine !SERVER_APP_HAS_DEFAULT_PORTS>
Listen 80
Listen 81
Listen 82
</IfDefine>
which appears to work fine. Presumably, if the mysterious SERVER_APP_HAS_DEFAULT_PORTS
parameter ever becomes true on my computer, it will be apparent what that's all about.
Upvotes: 6