Domanda

I installed httpd using brew.

I edited /usr/local/etc/httpd/httpd.conf and changed:

Listen 8080

to:

Listen 80

Restarted the service:

brew services restart httpd

But Apache's still listening on port 8080:

Benjamins-Mac-mini:~ benjamin$ sudo lsof -iTCP:80 -sTCP:LISTEN
Benjamins-Mac-mini:~ benjamin$ sudo lsof -iTCP:8080 -sTCP:LISTEN
COMMAND   PID     USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
httpd   24646 benjamin    4u  IPv6 0xcc42d5b2e5fcae09      0t0  TCP *:http-alt (LISTEN)
httpd   24647 benjamin    4u  IPv6 0xcc42d5b2e5fcae09      0t0  TCP *:http-alt (LISTEN)
httpd   24648 benjamin    4u  IPv6 0xcc42d5b2e5fcae09      0t0  TCP *:http-alt (LISTEN)
httpd   24649 benjamin    4u  IPv6 0xcc42d5b2e5fcae09      0t0  TCP *:http-alt (LISTEN)
httpd   24650 benjamin    4u  IPv6 0xcc42d5b2e5fcae09      0t0  TCP *:http-alt (LISTEN)
httpd   24651 benjamin    4u  IPv6 0xcc42d5b2e5fcae09      0t0  TCP *:http-alt (LISTEN)
httpd   34288 benjamin    4u  IPv6 0xcc42d5b2e5fcae09      0t0  TCP *:http-alt (LISTEN)
httpd   34289 benjamin    4u  IPv6 0xcc42d5b2e5fcae09      0t0  TCP *:http-alt (LISTEN)
httpd   34290 benjamin    4u  IPv6 0xcc42d5b2e5fcae09      0t0  TCP *:http-alt (LISTEN)

How can I force httpd to listen to port 80?

I tried restarting the service using sudo as port 80 is a privileged port, with no success.

È stato utile?

Soluzione

I figured it out.

I had started another instance of httpd by mistake earlier. I typed:

httpd --help

And while httpd doesn't recognize this command (what I was looking for was httpd -h), it did start a daemon, that was listening according to the old config file.

I'm very surprised that brew services start thought it was starting the server properly (brew services list did display it as started), even though it probably wasn't running because of the conflicting instance.

This is really confusing as start/stop did toggle between "started" and "stopped", even though it probably wasn't doing anything under the hood.

Altri suggerimenti

You probably have a directive like this with 8080:

<VirtualHost *:8080>
 ServerName xyz.com
 etc…
 </VirtualHost>

You need to change that to

<VirtualHost *:80> 

Make sure that you have correctly configured your directives for each subdomain you may have, including the default one (if it's been configured manually to listen to :8080 right after the name).

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a apple.stackexchange
scroll top