'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:
- that Apache is running (http://localhost gives 'It Works') and
- that forcing php (php -S localhost:8080) does not help.
Any idea ?
Solution 1:[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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mateus Barros Pinheiro |
