Thursday, September 1, 2022

[SOLVED] PHP 7.1 on macOS Sierra 10.12.3 - installed by Homebrew

Issue

I've just installed PHP 7.1 with Homebrew and when I type to Terminal $ sudo apachectl restart it returns this message AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 10.3.1.156. Set the 'ServerName' directive globally to suppress this message but everything seems to be working well.

phpinfo(); returns normal results...

php artisan serve returns different URL. http://127.0.0.1:8000 instead of http://localhost:8000...

PHP installation steps:

brew tap homebrew/dupes

brew tap homebrew/versions

brew tap homebrew/homebrew-php

brew install php71 --with-httpd24

In httpd file:

LoadModule php7_module /usr/local/opt/php71/libexec/apache2/libphp7.so

<IfModule php7_module>
 AddType application/x-httpd-php .php
 AddType application/x-httpd-php-source .phps

 <IfModule dir_module>
  DirectoryIndex index.html index.php
 </IfModule>
</IfModule>

What should I do to avoid this error message?

And how can I get the URL http://localhost:8000 from Laravel back?

Ok, I found if I add ServerName localhost to the httpd.conf (on this path /usr/local/etc/apache2/2.4/httpd.conf) the warning is gone - thank you to Andrew

But laravel still return 127.0.0.1... any ideas? Is it correct installation of PHP 7 on Mac?


Solution

After installation PHP 7 brew install php71 --with-httpd24 run this command brew unlink httpd24 then edit httpd.conf on macOS Apache (/etc/apache2/httpd.conf)...



Answered By - user2703424
Answer Checked By - Candace Johnson (WPSolving Volunteer)