13

I'm still having some problems on using httpd (aka Apache2) after the update of my MacOs on BigSur.

I tried to make a clean reinstall of apache2 using the brew httpd services (like said in a lot of tutorials) but it still not working. I make a summary of the steps taked and I'll add some debug command.

To reinstall I done:

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

brew install httpd

After that I reboot and launched the command:

brew services start httpd
==> Successfully started `httpd` (label: homebrew.mxcl.httpd)

But if I run the following command:

brew services list
Name              Status  User            Plist
dnsmasq           started root            /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
fuseki            stopped                 
httpd             error   matteo.ceradini /Users/matteo.ceradini/Library/LaunchAgents/homebrew.mxcl.httpd.plist
mongodb-community started matteo.ceradini /Users/matteo.ceradini/Library/LaunchAgents/homebrew.mxcl.mongodb-community.plist
unbound           stopped 

As you can see the httpd is in an error status (in fact going to localhost:8080 I get an error) and I can't understand why.

Any suggestion how to fix this?

Thank you.

ceradini
  • 455
  • 1
  • 3
  • 11

7 Answers7

18

Something seems to not working, but still I can't find why.

I stopped all the services (either sudo brew and brew without sudo), and next running the commands:

sudo lsof -i :80
sudo lsof -i :8080
sudo lsof -i tcp:80
sudo lsof -i tcp:8080

the results is always nothing. But if I run:

sudo brew services start httpd    
==> Successfully started `httpd` (label: homebrew.mxcl.httpd)

The httpd will not start (even if in the terminal command it says yes):

sudo brew services list
               
httpd             error   root            /Library/LaunchDaemons/homebrew.mxcl.httpd.plist

And if I check the apachetl error I get always that the port 80 is occupied, even if there isn't processes on that port:

apachectl -e error
(48)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
AH00015: Unable to open logs

I urgently need to find a solution for this bug. It seems that in some httpd is corrupted, even if I uninstall and reinstall again

UPDATE:

I really don't know how I did it, but now it's working. I stopped all the brew httpd services and I restard apache using the command:

sudo apachectl -k start

and that worked for me

ceradini
  • 455
  • 1
  • 3
  • 11
  • 3
    Wow, same issue here as Big Sur updated. All manner of misleading brew service status. I had to first shut all the brew services down, then run `sudo apachectl -k stop` before running `sudo apachectl -k start` which brought brew's httpd / Apache back to life. – chopstik Mar 10 '21 at 02:51
  • Leave the ServerName in httpd.conf commented (don't set it explicitly). If you need to respond to a specific host name, use virtual hosts. – Ted Stresen-Reuter Apr 12 '21 at 10:57
11

I just had exactly the same issue on Monterey. As digging in, it seems that the problem was a symbol not found ( _apr_bucket_alloc_aligned_floor ), expected in: /usr/lib/libaprutil-1.0.dylib.

Reinstalling apr-util fixed my case:

brew reinstall apr-util
Sébastien S.
  • 1,444
  • 8
  • 14
1

FIRST ANSWER: Sounds like the service started OK then later (or immediately) died, and reports an error. Using the command 'apachectl -e error' should provide details, but you'd wanna check the logs ('vi /usr/local/var/log/httpd/error_log', then shift-G [to goto end]).

SECOND (EXPLAINATION) ANSWER: " If you use (sudo) brew services ... to start httpd you have to use the proper (sudo) brew services list command to check the status:

If you start it as root then list it with root privs:

sudo brew services start httpd > sudo brew services list

or with user privs:

brew services start httpd > brew services list. "

  • Hi Yuma, can you please take a look to my last answer with the execution of the commands that you suggested? – ceradini Jan 13 '21 at 22:07
1

Judging by the result from sudo apachectl -e error, it cannot use port 8080 because another app is using it.

The first warning - can be ignored - or set the FQDN in httpd.conf. Usually this is in the '/usr/local/etc/httpd' folder. Edit with sudo vi /usr/local/etc/httpd/httpd.conf. (I like vi - use whatever you feel comfortable with - sudo open -e /usr/local/etc/httpd/httpd.conf is common). The default config has the line #ServerName www.example.com:8080, remove that '#' and replace 'www.example.com:8080' with 'MBP-Matteo.local' - or whatever.

Type sudo lsof -i tcp:8080 to list all apps using port 8080, mostly only apps that LISTEN are important.

Next error: You must stop that other app which is using port 8080 (and prevent starting on boot) - or - set Apache to use a different port. (Note: If you choose a port lower than 1024, 'sudo' must be used to start the service.) Usually port 80 is devoted to Apache. The port to be used can be set by editing the config file, as above, then find the line 'Listen 8080', and replace 8080 with the desired port.

After the changes, try to start again with [sudo] 'brew services start httpd'. Then check with [sudo] 'brew services list'. Hopefully all works fine.

0

FIRST ANSWER: Sounds like the service started OK then later (or immediately) died, and reports an error. Using the command 'apachectl -e error' should provide details, but you'd wanna check the logs ('vi /usr/local/var/log/httpd/error_log', then shift-G [to goto end]).

The first command gives this result:

sudo apachectl -e error
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using MBP-Matteo.local. Set the 'ServerName' directive globally to suppress this message
(48)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:8080
no listening sockets available, shutting down
AH00015: Unable to open logs

And the file '/usr/local/var/log/httpd/error_log' is empty

SECOND (EXPLAINATION) ANSWER: " If you use (sudo) brew services ... to start httpd you have to use the proper (sudo) brew services list command to check the status:

The results doesn't change if I executed brew commands with both sudo or without (given that previously I was using without sudo)

Any suggestions?

ceradini
  • 455
  • 1
  • 3
  • 11
0

my solution, stop httpd service, then check httpd.conf and check DocumentRoot "/opt/homebrew/var/www" <Directory "/opt/homebrew/var/www"> when returning to the original state this route, restart the httpd service and it worked without problems.

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 14 '22 at 21:29
0

A simple brew reinstall httpd fixed it for me. All .conf files remained intact after reinstall for anyone wondering.

Yes Barry
  • 9,514
  • 5
  • 50
  • 69