2WFR
2WFR

Reputation: 145

Apache, MySQL & PHP on macOS Big Sur. PHP not working

I am trying to Apache, MySQL & PHP on macOS Big Sur.

I have followed this guide: https://tobschall.de/2020/11/01/big-sur-mamp/

And have configured my /etc/apache2/extra/httpd-vhosts.conf as

<VirtualHost *:80>
  DocumentRoot "/Users/myname/Sites/test"
  ServerName local.idex
</VirtualHost>

and my /etc/hosts

127.0.0.1       localhost local.test
255.255.255.255 broadcasthost
::1             localhost

if I put the following php file (phpinfo.php)

echo '<?php phpinfo();' > /Library/WebServer/Documents/phpinfo.php

in the test directory and type http://localhost/phpinfo.php in a browser, I get

echo '<?php phpinfo();' > /Library/WebServer/Documents/phpinfo.php

which is basically what I put on the file.

Looks like the php is not working :-(

I have checked:

  1. that Apache is running (http://localhost gives 'It Works') and
  2. that forcing php (php -S localhost:8080) does not help.

Any idea ?

Upvotes: 1

Views: 646

Answers (1)

For those with the same problem. I found the solution here (https://wpbeaches.com/install-apache-mysql-php-on-macos-11-big-sur-and-earlier-macos/) Just add

LoadModule php7_module libexec/apache2/libphp7.so 

in your /etc/apache2/httpd.conf file.

Upvotes: 1

Related Questions