{"id":841,"date":"2020-06-13T09:38:52","date_gmt":"2020-06-13T15:38:52","guid":{"rendered":"http:\/\/www.schwie.com\/brad\/?p=841"},"modified":"2020-06-13T10:47:29","modified_gmt":"2020-06-13T16:47:29","slug":"macos-server-on-catalina-and-php-7-3","status":"publish","type":"post","link":"https:\/\/www.schwie.com\/brad\/?p=841","title":{"rendered":"macOS Server on Catalina and php 7.3.8"},"content":{"rendered":"<p>I&#8217;ve posted ways to <a href=\"https:\/\/www.schwie.com\/brad\/?p=325\">update<\/a> 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.<\/p>\n<p>Before hitting the steps below, High Sierra&#8217;s sandboxing and needing to edit system files are difficult unless you boot from recovery mode to temporarily disable SIP, &#8220;csrutil disable&#8221;. 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&#8217;s libphp7.so file from &#8220;\/usr\/libexec\/apache2&#8221;. <\/p>\n<p>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):<\/p>\n<p>curl -s http:\/\/php-osx.liip.ch\/install.sh | bash -s 7.3<br \/>\nsudo pico \/Library\/Server\/Web\/Config\/apache2\/httpd_server_app.conf<\/p>\n<p>The second command allows you to edit &#8220;\/Library\/Server\/Web\/Config\/apache2\/httpd_server_app.conf&#8221;. Search for the line with &#8220;php7_module&#8221; and change the file path to point to the new libphp7.so file:<\/p>\n<p>LoadModule php7_module \/usr\/local\/php5\/libphp7.so<\/p>\n<p>Notice that this path is different than &#8220;\/usr\/local\/php4\/php5-7.3.8-20190811-205217&#8221;, but the above path has an alias that points to 7.3.8 and should enable future upgrades (hint, when we&#8217;re ready for php 7.4 and beyond).<\/p>\n<p>2. Verify that the updated php is running with the following command:<\/p>\n<p>schwie:apache2 bradschwie$ php -version<br \/>\nPHP 7.3.8 (cli) (built: Aug 11 2019 20:50:16) ( NTS )<br \/>\nCopyright (c) 1997-2018 The PHP Group<br \/>\nZend Engine v3.3.8, Copyright (c) 1998-2018 Zend Technologies<br \/>\n    with Zend OPcache v7.3.8, Copyright (c) 1999-2018, by Zend Technologies<br \/>\n    with Xdebug v2.7.2, Copyright (c) 2002-2019, by Derick Rethans<\/p>\n<p>3. To verify that php 7.3.8 is running on your webserver, restart your machine (or <a href=\"https:\/\/codedmemes.com\/lib\/server-5-2-not-ready\/\">restart the Apache web server from Terminal<\/a>):<\/p>\n<p>sudo \/Applications\/Server.app\/Contents\/ServerRoot\/usr\/sbin\/server-apachectl graceful<\/p>\n<p>To complete this verification, I recommend temporarily placing an &#8220;<a href=\"https:\/\/getgrav.org\/blog\/macos-catalina-apache-multiple-php-versions#Validating\">info.php<\/a>&#8221; 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 &#8220;\/usr\/local\/php5\/lib\/php.ini&#8221;. I keep <a href=\"http:\/\/schwie.com\/info.php\">the info.php file on my server<\/a>, but for security purposes I recommend commenting out the body of the file after obtaining your php configuration information.<\/p>\n<p>4. After completing step 3, I moved back to my blog and noticed all sorts of JIT errors. <a href=\"https:\/\/wordpress.stackexchange.com\/questions\/326345\/wordpress-warning-preg-replace-jit-compilation-failed-no-more-memory\">Others<\/a> recommended disabling JIT from the php.ini file linked above, so I did the same by adding:<\/p>\n<p>pcre.jit=0<\/p>\n<p>5. Finally, my blog was complaining that it didn&#8217;t have the imagick php extension. My server has brew, so adding imagick is pretty easy using <a href=\"https:\/\/ma.ttias.be\/install-phps-imagick-extension-on-mac-with-brew\/\">Mattias&#8217; instructions<\/a>, but after his step to install imagemagick, install autoconf <a href=\"https:\/\/stackoverflow.com\/questions\/31583646\/cannot-find-autoconf-please-check-your-autoconf-installation-xampp-in-centos\">to avoid errors<\/a> with the pecl command:<\/p>\n<p>brew install autoconf<\/p>\n<p>So far so good. I&#8217;ll keep you posted when I make changes or move along to 7.4.<\/p>\n<p>Last note, I <a href=\"https:\/\/github.com\/munkireport\/munkireport-php\/wiki\/macOS-Server\">also looked at instructions posted here<\/a>, but I don&#8217;t believe I needed them in the end.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;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 &hellip; <a href=\"https:\/\/www.schwie.com\/brad\/?p=841\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-841","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.schwie.com\/brad\/index.php?rest_route=\/wp\/v2\/posts\/841","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.schwie.com\/brad\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.schwie.com\/brad\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.schwie.com\/brad\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.schwie.com\/brad\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=841"}],"version-history":[{"count":5,"href":"https:\/\/www.schwie.com\/brad\/index.php?rest_route=\/wp\/v2\/posts\/841\/revisions"}],"predecessor-version":[{"id":847,"href":"https:\/\/www.schwie.com\/brad\/index.php?rest_route=\/wp\/v2\/posts\/841\/revisions\/847"}],"wp:attachment":[{"href":"https:\/\/www.schwie.com\/brad\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=841"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.schwie.com\/brad\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=841"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.schwie.com\/brad\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=841"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}