I'm having issues getting PHP 7.4.6 work with Apache 2.4 on Macos Catalina. I tried some solutions but none of them worked, still getting a blank page when running PHP code via Apache. Both Apache and PHP were installed using Homebrew.
Running brew info:
rocky@rockysMacBookPro ~ % brew info
[email protected]
php: stable 7.4.6 (bottled), HEAD
General-purpose scripting language
https://www.php.net/
/usr/local/Cellar/php/7.4.6 (520 files, 76.1MB) *
Poured from bottle on 2020-05-15 at 02:41:44
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/php.rb
==> Dependencies
Build: httpd ✘, pkg-config ✘
Required: apr ✔, apr-util ✔, argon2 ✔, aspell ✔, autoconf ✔, curl-openssl ✔, freetds ✔, freetype ✔, gettext ✔, glib ✔, gmp ✔, icu4c ✔, jpeg ✔, libffi ✔, libpng ✔, libpq ✔, libsodium ✔, libzip ✔, oniguruma ✔, openldap ✔,
[email protected] ✔, sqlite ✔, tidy-html5 ✔, unixodbc ✔, webp ✔
==> Options
--HEAD
Install HEAD version
==> Caveats
To enable PHP in Apache add the following to httpd.conf and restart Apache:
LoadModule php7_module /usr/local/opt/php/lib/httpd/modules/libphp7.so
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
Finally, check DirectoryIndex includes index.php
DirectoryIndex index.php index.html
The php.ini and php-fpm.ini file can be found in:
/usr/local/etc/php/7.4/
To have launchd start php now and restart at login:
brew services start php
Or, if you don't want/need a background service you can just run:
php-fpm
==> Analytics
install: 53,658 (30 days), 140,934 (90 days), 499,288 (365 days)
install-on-request: 50,277 (30 days), 131,496 (90 days), 461,925 (365 days)
build-error: 0 (30 days)
Httpd.conf:
LoadModule php7_module /usr/local/opt/php/lib/httpd/modules/libphp7.so
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
.bash_profile:
export PATH=/usr/local/Cellar/php/7.4.6/bin:$PATH
Renamed php-fpm.conf.default:
sudo cp /private/etc/php-fpm.conf.default /private/etc/php-fpm.conf
Running php-fpm:
rocky@rockysMacBookPro ~ % php-fpm
[21-May-2020 13:36:05] WARNING: Nothing matches the include pattern '/private/etc/php-fpm.d/*.conf' from /private/etc/php-fpm.conf at line 143.
[21-May-2020 13:36:05] ERROR: failed to open error_log (/usr/var/log/php-fpm.log): No such file or directory (2)
[21-May-2020 13:36:05] ERROR: failed to post process the configuration
[21-May-2020 13:36:05] ERROR: FPM initialization failed
Line 143 in php-fpm:
include=/private/etc/php-fpm.d/*.conf
Running php-fpm -i
'--sysconfdir=/private/etc'
Now I'm out of ideas and any help is appreciated. Thank You