The page cannot be accessed after apache is configured with php7 under mac. It seems that apache is not successful. It is normal to switch back to php5.

encountered something similar to this problem:
https://codeshelper.com/q/10.

"

upgrade php to php7.2.8 by brew first

brew install php72

look it up with the command.

php -v

.

PHP 7.2.8 (cli) (built: Jul 19 2018 12:15:24) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.8, Copyright (c) 1999-2018, by Zend Technologies
    
   

modify the configuration of apache.

sudo vim /etc/apache2/httpd.conf

add these lines:

LoadModule php7_module /usr/local/opt/php/lib/httpd/modules/libphp7.so

<FilesMatch \.php$>

 SetHandler application/x-httpd-php

</FilesMatch>

after restart,

the browser of the original accessible project (ThinkPHP5 project) reported an error as:
Picture description

View: log,
sudo vim / private/var/log/apache2/error_log

[Wed Aug 15 12 AH00163: Apache/2.4.29 (Unix) PHP/5.6.29 configured 20 AH00163: Apache/2.4.29 (Unix) PHP/5.6.29 configured 50.539556 2018] [mpm_prefork:notice] [pid 36582] AH00163: Apache/2.4.29 (Unix) PHP/5.6.29 configured-- resuming normal operations
[Wed Aug 15 12 AH00163: Apache/2.4.29 (Unix) PHP/5.6.29 configured 50.539939 2018] [core:notice] [pid 36582] AH00094: Command line:"/ usr/sbin/httpd-D FOREGROUND"
[Wed Aug 15 1232 AH00163: Apache/2.4.29 (Unix) PHP/5.6.29 configured 49.649922 2018] [mpm_prefork:notice] [pid 36582] AH00169: caught SIGTERM, shutting down

if I comment out the lines added above. Once again, the php5.6
project will open normally.

later upgraded apache.
brew install httpd24

DocumentRoot is /usr/local/var/www.

The default ports have been set in /usr/local/etc/httpd/httpd.conf to 8080 and in
/usr/local/etc/httpd/extra/httpd-ssl.conf to 8443 so that httpd can run without sudo.

To have launchd start httpd now and restart at login:
  brew services start httpd
Or, if you don"t want/need a background service you can just run:
  apachectl start
==> Summary
  /usr/local/Cellar/httpd/2.4.34: 1,633 files, 26.6MB
==> Caveats
==> httpd
DocumentRoot is /usr/local/var/www.

The default ports have been set in /usr/local/etc/httpd/httpd.conf to 8080 and in
/usr/local/etc/httpd/extra/httpd-ssl.conf to 8443 so that httpd can run without sudo.

To have launchd start httpd now and restart at login:
  brew services start httpd
Or, if you don"t want/need a background service you can just run:
  apachectl start
macdeMacBook-Pro:~ mac$ brew services start httpd
==> Successfully started `httpd` (label: homebrew.mxcl.httpd)


Php
Apr.09,2021

replace it with nginx

Menu