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.

10 thoughts 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

  2. I’m also on high sierra, using server 5.6.3.

    http://php-osx.liip.ch has stopped at 7.3. How do we get 7.4?

    I don’t want to use brew, so I thought I could use 7.4 which comes with MAMP. I got it to show on the CLI, but not on the server app apache (phpinfo).

    Do you know how to make the server app apache use the MAMP PHP?

  3. Scott,

    I am sticking with brew and haven’t gone the MAMP route, so I wouldn’t be much help there. I might reconsider MAMP if my Mac mini ever leaves macOS Server, but for now I’ll stick with brew for easier package management.

    In relation to your question, when I have more free time I’m going to try and get Server.app to use the updated PHP I installed with brew. These pages are ones that I saved for future reference that I plan to use to help Server.app see the new PHP version and may help you with linking to the latest Apache you install:

    https://discussions.apple.com/thread/7679398
    https://codedmemes.com/lib/server-5-2-not-ready/

  4. Brad,
    Thanks for the response.

    Are you saying that you are not getting the server app apache to use the brew php (phpinfo}? If not, then what good is it?

    I mean, I don’t understand what the use of having the version of php we want on the CLI, but not in the apache webserver where we need it.

    Thanks,
    Scott

  5. Scott,

    Apache running on macOS Server on my Mac mini is using the latest PHP version I installed through brew, but I noticed that the app Server.app is not able to use the latest PHP version to display some run-time info within Server.app. For instance, with the stock version of PHP installed Server.app shows charts of Processor Usage, Memory Usage, Memory Pressure, and Network Traffic. As you can see in my Server.app screenshots, below, all these charts are now blank and I think this is because I upgraded to the latest version of PHP and somehow Server.app isn’t compatible.

    I upgraded PHP to a more recent version as WordPress and other software installed on my Mac mini require it and I was fine to leave Server.app marooned with the issue described above; however, the links in my previous post may help me to revitalize Server.app so it can start displaying the charts I mention above.

    I could be remembering wrong, but I think one of the reasons why I stayed away from MAMP is because it can’t be configured as much as brew-installed software allows.

    Brad

    Network Traffic
    Memory Pressure
    Processor Usage
    Memory Pressure
    PHP Info

  6. Brad,
    It looks like it’s using the llip.ch version of 7.3 still as in your last screen shot above.

    I too am using wordpress and many plugins and wordpress itelf keep nagging for the latest php.

    I tried brew a few years ago and didn’t like how it seems to put loads of stuff I didn’t think I needed on the system, so I uninstalled it. But if you recommend it, at least for php, maybe I should try again.

    So are you able to get php 7.4 installed and seen by the server app apache (phpinfo). If so, are there any tips or help you can offer about how to get it working so that all the sites I have under “Websites” in server app are actually using php 7.4?

    Thanks a lot!

  7. Scott,

    When I visited this last year, I think 7.3.8 was the highest we could go to using php-osx.liip.ch. I haven’t looked for other instructions out there, but I’m assuming we’ll need to write our own since not many of us still use macOS Server (and version 5.6.1).

    After the holiday, I need to spend time repairing apache on macOS Server 5.6.1: some of my hosted websites no longer load. And after that I need to renew and automate a few certificates. After that, I’ll likely consider PHP 8 and writing some macOS Server-specific upgrade instructions on my blog. If you jump into it before then, these instructions might be a starting point.

    Have you seen any good resources/communities/websites pop up that continue to support macOS Server? I’d prefer to keep running 5.6.1 going as long as security updates from Apple remain supported. Beyond that, it might get tricky.

    Brad

  8. Brad,
    Sounds like you want to do what my boss has in mind. Stay on Mac server as long as possible.

    Actually server version 5.6.3 is the latest you can use with High Sierra.

    So I’m confused. Are you stuck at php 7.3 with php-osx.liip.ch? Or are you actually using brew and getting php 7.4 in server app apache?

    Thanks,
    Scott

  9. Scott,

    You are correct, 5.6.3 is the latest, but I kept mine at 5.6.1. I thought Apple pulled away another feature in 5.6.3 and that’s why I stayed at 5.6.d – did your server keep all of its services on 5.6.3?

    Yeah, I’m currently stuck at 7.3.8 with php-osx.liip.ch. I plan to use brew to go to 7.4 (and beyond) later.

    Brad

  10. Yes, it seems all services were there in 5.6.3. You just have to make them show in the “View” menu.

    I keep thinking there’s a way I could use the MAMP php, but I just cant figure it out. I guess I’ll try brew, but I don’t want to.

    Have you heard of something called “Docker”? Here is an article about it:
    https://jasonmccreary.me/articles/install-apache-php-mysql-macos-docker-local-development/

    Or what about Fink Project:
    https://www.finkproject.org/

    These seem to have ability to install/update php, but it looks like it’s the OS version, not geared to the Apple server like we need.

    One other question if you don’t mind. When you do a phpinfo and you see the php.ini file that’s currently loaded, do you know where that path is defined? I looked in the apache conf but it doesn’t seem to be there. Any ideas where that would be?

    Thanks!

Leave a Reply

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