Getting Apache 2.4.46 + PHP 7.3.22 Going on macOS 11 Bug Sur
Friday, November 13th, 2020This morning, with the update to macOS 11 Big Sur it was time perform the ritual of getting the old web development tools that I've used in the past going again - this time on macOS 11. Now I haven't used PHP in ages, and this looks to be the last time I'll have to worry about this, as Apple is going to drop PHP from their releases, and they have already dropped their Postgres support in PHP. But let's get done what we can.
Activating UserDir in Apache 2.4.46
As in the previous updates, the UserDir extension is not enabled by default, so we need to get that going right away. This enables the code to be run from the development directories, and that's a big time-saver. First, we need to enable the UserDir module in Apache, and then make a specific config file for the user in question. Start by editing /etc/apache2/httpd.conf and line 184 needs to be uncommented to read:
LoadModule userdir_module libexec/apache2/mod_userdir.so
and then similarly on line 521 uncomment the line to read:
Include /private/etc/apache2/extra/httpd-userdir.conf
Next, make sure that the file we just included is set up right for including the user directories. Edit /etc/apache2/extra/httpd-userdir.conf and line 16 needs to be
uncommented to read:
Include /private/etc/apache2/users/*.conf
At this point, you need to make sure you have at least one file in the /etc/apache2/users/ directory for each user, like: drbob.conf:
<Directory "/Users/drbob/Sites/"> Options FollowSymLinks Indexes MultiViews ExecCGI Require all granted </Directory>
where the last line - Require all granted is new as of Apache 2.4, and without it you will get errors like:
[Thu Dec 18 10:41:32.385093 2014] [authz_core:error] [pid 55994] [client fe80::7a31:c1ff:fed2:ca2c:58108] AH01630: client denied by server configuration: /Users/drbob/Sites/info.php
Activating PHP in Apache
The mext thing to do is to activate PHP in the supplied Apache 2 with macOS 11. This is line 187 in the file - /etc/apache2/httpd.conf and you need to uncomment it to read:
LoadModule php7_module libexec/apache2/libphp7.so
and then verify a file called /etc/apache2/other/php7.conf exists and contains:
<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>
which does all the other PHP configuration in a separate file to make upgrades easy.
Finishing Up
At this point, a simple restart of apache:
$ sudo apachectl restart
and everything should be in order. Hit a URL that's a static file with the contents:
<?php phpinfo(); ?>
and you should see all the details about the PHP install - it's all there, as in older releases, but it was surprising to me to see that there was no longer any support for Postgres within the PHP version that was delivered with Big Sur. More to the point - the warning is clear - PHP will be dropped in a future macOS release. Until then, we still have:
- PHP 7.3.22
- MySQL 5.0.12
- SQLite3 3.28.0
so things are still there - kinda... MySQL is still supported, for those that want that, and SQLlite3, which is likely my most logical choice, but in truth... this is progress. Folks don't do PHP development like they used to, and so it's going to go away. I'll miss it, but maybe Homebrew will have something - and I remember building it all from source before... so I can do it again - if I need to.