macOS Server on Catalina and php 7.3.8

I’ve posted ways to update php on macOS Server. My Mac mini is now running macOS Server 5.6.1 on macOS High Sierra and WordPress dutifully reminded me it is time to update php to a supported version, so read on for how it came together.

Before hitting the steps below, High Sierra’s sandboxing and needing to edit system files are difficult unless you boot from recovery mode to temporarily disable SIP, “csrutil disable”. Or, if you have the luxury I have, I was able to boot from my backup and edit my main drive. Doing this allowed me to delete Apple’s libphp7.so file from “/usr/libexec/apache2”.

1. Open Terminal and execute one line of code to get the latest stable php version, 7.3.8 at the time of this post, using the following command (and yes, even though below says 7.3, it will grab 7.3.8):

curl -s http://php-osx.liip.ch/install.sh | bash -s 7.3
sudo pico /Library/Server/Web/Config/apache2/httpd_server_app.conf

The second command allows you to edit “/Library/Server/Web/Config/apache2/httpd_server_app.conf”. Search for the line with “php7_module” and change the file path to point to the new libphp7.so file:

LoadModule php7_module /usr/local/php5/libphp7.so

Notice that this path is different than “/usr/local/php4/php5-7.3.8-20190811-205217”, but the above path has an alias that points to 7.3.8 and should enable future upgrades (hint, when we’re ready for php 7.4 and beyond).

2. Verify that the updated php is running with the following command:

schwie:apache2 bradschwie$ php -version
PHP 7.3.8 (cli) (built: Aug 11 2019 20:50:16) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.8, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.8, Copyright (c) 1999-2018, by Zend Technologies
with Xdebug v2.7.2, Copyright (c) 2002-2019, by Derick Rethans

3. To verify that php 7.3.8 is running on your webserver, restart your machine (or restart the Apache web server from Terminal):

sudo /Applications/Server.app/Contents/ServerRoot/usr/sbin/server-apachectl graceful

To complete this verification, I recommend temporarily placing an “info.php” file on your webserver to know which php version your webserver is relying on and where the php.ini file is saved. Mine was stored here “/usr/local/php5/lib/php.ini”. I keep the info.php file on my server, but for security purposes I recommend commenting out the body of the file after obtaining your php configuration information.

4. After completing step 3, I moved back to my blog and noticed all sorts of JIT errors. Others recommended disabling JIT from the php.ini file linked above, so I did the same by adding:

pcre.jit=0

5. Finally, my blog was complaining that it didn’t have the imagick php extension. My server has brew, so adding imagick is pretty easy using Mattias’ instructions, but after his step to install imagemagick, install autoconf to avoid errors with the pecl command:

brew install autoconf

So far so good. I’ll keep you posted when I make changes or move along to 7.4.

Last note, I also looked at instructions posted here, but I don’t believe I needed them in the end.

1 thought on “macOS Server on Catalina and php 7.3.8

  1. Pingback: Replace PHP 5.5/5.6 with PHP 7 on OS X Server (Yosemite) « Schwie's Pad

Leave a Reply

Your email address will not be published. Required fields are marked *