Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

localhost not working on Big Sur (Apache & Homebrew)

I know there are dozens of questions about Apache not working, but nothing seems to solve it for me. I'm on macOS Big Sur 11.0.1.

I installed Apache with brew install httpd and then brew services start httpd. Everything seems to be okay, but going to http://localhost/ gives me "This site can't be reached" error. http://127.0.0.1/ also gives that error. My /etc/hosts configuration seems to be fine.

I don't understand what's wrong. What can I do to find out the issue?

like image 724
Robo Robok Avatar asked Dec 01 '20 00:12

Robo Robok


People also ask

How do I start apache on Mac Big Sur?

Apache and php comes pre installed in mac OS Big Sur, You will just need to activate them using terminal. To start apache type the following command in the terminal and run. You need to write “sudo” before the actual command. We use sudo, which stands for “super-user do,” to run apps with higher rights.

Is apache installed on macOS Big Sur?

macOS 11.0 Big Sur comes with Apache 2.4 pre-installed.

Can you run apache on Mac?

The homebrew package installer can be used to install Apache 2.0 on MacOS. The installer installs the Apache HTTP server on the location /usr/local/Cellar/httpd . Apache provides a service named as apachectl which needs to be started in order to start Apache.


Video Answer


1 Answers

I assume you have tried to follow https://getgrav.org/blog/macos-bigsur-apache-multiple-php-versions tutorial. If not no worries. I followed this tutorial and I got the same issue.

As per my understanding you have updated to BigSur from previous version and there you have used sudo to install apache and php etc. Now it will not work due to permission issues.

I am able to make it run with the following steps

  1. Change Listen 80 to Listen 127.0.0.1:80 in /usr/local/etc/httpd/httpd.conf
  2. use sudo /usr/local/bin/httpd -k start to start your httpd

Rest follow the tutorial to install multiple versions of PHP, enabling PHP in httpd.conf file and PHP version switcher. After switching the version you must stop and start the httpd via sudo command i mentioned above.

So looks like things are working with this. I hope if I'm able to set proper permissions then I no longer need the sudo. And if you are at the tutorial, please check the comments at the bottom

Take care

like image 136
Aamir Mahmood Avatar answered Oct 08 '22 18:10

Aamir Mahmood