macOS 12.0 -where oh where is PHP

PHP seems to be missing from this release.

Post not yet marked as solved Up vote post of jwestveer Down vote post of jwestveer
26k views
  • No one should use system PHP anyway on macOS, It is an old and insecure version. I would recommend installing PHP via brew  https://github.com/shivammathur/homebrew-php

  • Hi, I installed PHP via brew from shivammathur, (macOS Monterrey) How do I activate PHP? It's not being interpreted, what I see is the code when I load a PHP file. Thanks in advance

  • Have you tried making changes in httpd.conf file to read php files ?

Replies

PHP has been removed in macOS Monterey.

  • That would be unfortunate. How can we convince you'll to put it back in the release.

  • brew install php

  • I have been trying to compile it myself. Instructions at https://mac-dev-env.patrickbougie.com/php/ are close. Perhaps some trial and error. First issue is apsx is missing from apache

This is a giant step backwards. One of the nice things about macOS is the built in apache including PHP. Please reconsider this.

  • It's been deprecated since 10.15 https://developer.apple.com/documentation/macos-release-notes/macos-catalina-10_15-release-notes#Scripting-Language-Runtimes

    12.0 is a major release, so Apple did the right thing.

  • This is a giant step forward. The version of Php that Apple ships with is almost always an outdated version, without the useful extensions. For anyone working with php, there are now much easier ways to install and manage multiple versions at once (brew, docker etc) without having to deal with outdated and conflicting versions. Plus, it cleans up the system for the rest of us. Thanks Apple! good call

  • Also running PHP binary would've given hints

    ⇒ /usr/bin/php -v WARNING: PHP is not recommended PHP is included in macOS for compatibility with legacy software. Future versions of macOS will not include PHP. PHP 7.3.24-(to be removed in future macOS) (cli) (built: May 8 2021 09:40:37) ( NTS )

Add a Comment

MAMP (https://www.mamp.info/en/mac/) is also an option.

  • Option, yes. A good one? That's debatable. ;) I would strongly encourage folks to look into Lando and Docker (or similar) for local development. PHP is useful to have for some CLI stuff, but if you're doing more than that, you're best off containerizing your stuff for the sake of consistency.

Add a Comment

No one should use system PHP anyway on macOS, It is an old and insecure version. I would recommend installing PHP via brew  https://github.com/shivammathur/homebrew-php

  • Hi, I installed PHP from this repository, what do I have to do now to activate PHP? I'm using macOS Monterrey

  • A little search will take you to pages on how to configure apache to enable PHP. https://websitebeaver.com/set-up-localhost-on-macos-high-sierra-apache-mysql-and-php-7-with-sslhttps

    The recommended version is PHP 8.

Add a Comment

Can I add my tuppence-worth as another request for PHP to return to macOS 12. My first thought was that it was a licensing issue, but PHP uses a BSD-style license, so I can't understand the rationale for removing it.

  • The rationale for removing it is that people should be able to choose what to install (or not install) on their system to reduce version conflicts and to remove security flaws, as well as to have a smaller OS footprint. Users should be able to select the version(s) they prefer. Embedding a specific version in the OS exposes users to all the security issues of that version.

Add a Comment

Via MacPorts ( https://www.macports.org/ ):

port install php
  • Have you actually tried that?

  • It doesn't work. Also, I second telling folks to port or brew is asinine, considering there's no consensus on which package manager to trust or is more reliable.

Add a Comment

It seems that it would be easier for one person at apple to upgrade php, rather then millions of users having to do so. Laziness.

  • Software get updated all the time. Users / devs might need or want versions other than that provided by Apple. Including a specific version of software in an OS exposes users to its security vulnerabilities, even if they don’t need that software or that version of it. It provides ample opportunities for version conflicts if someone wants to use a different version than the built in. It also bloats the distribution size.

    Apple won’t (& shouldn’t) release a new OS every time se third-party software is updated. But users might want to upgrade themselves. Even if Apple did update macOS with every new third-party software version, changing the version of languages / frameworks all the time would frequently break programs that relied on them.

    Apple might also object to new licenses in newer versions of a distribution, like how they keep providing an ancient version of bash.

    Please stop embarrassing yourself with your uninformed posts on this topic.

    If you want to install software, and to either pin it to a specific version or to easily get the newest, use one of the many software managers out there.

Add a Comment

The situation is similar for Perl. You can install perl separately via homebrew or macports, or via plenv (https://github.com/tokuhirom/plenv) or perlbrew (perlbrew.pl). This is preferred anyway since in the last few OSX releases, Apple has edited some of the internal Perl toolchain modules (such as ExtUtils::MakeMaker) in a broken way without talking to the developer team (or even responding to repeated pleas to fix their broken changes).

100% the right move. Dockerize your app and move on.

docker pull php:alpine
  • What does this even mean?

    Besides, docker: Command not found.

  • install docker first tuxedobob0. docker.com

Add a Comment

O.k., they removed php... some call it a good thing, some call it a bad thing. But; why remove PHP, but keep apache?

  • Because Apache can serve even non-PHP web apps.

Add a Comment

Buna hiç gerek yoktu. İşi zora sokmak demek bu. Php eski ve kullanılmayan bir dil değil.. Web tabanlı en gelişmiş dillerden biri durumunda ve güncellenmeye devam ediliyor. Apple desteğini çekerek iyi yapmadı. Umarım konu hakkında gerekli iyileştirmeleri yaparlar ve php desteği geri gelir.

It would be good if Apple allows custom installation that makes php executable into /usr/bin. Right now, the situation is breaking some tools, such as phpcs in PHPStorm. I tried to solve it by installing PHP with Homebrew, and it doesn't solve the problem.

What upsets me about the move to big sur and then monterey is that the upgrade program should check that i have apache, php and mysql and if it finds that there it should stop and say: hey man, this upgrade is going to create problems for you ... do you want to think about it before you proceed?

So what I'm going top do now is upload the (daily) backedup MySQL database to a hosting service that will also support PHP. Then I'll find the time to work out how to migrate my admin systems to Monterey - and then buy a new Macbook Pro - after I know how to migrate to that environment.

PHP is not insecure if you use a supported version: https://www.php.net/supported-versions.php

Apple is not the only company to stop bundling it and give the responsibility to the end user. Claris also used to ship PHP with FileMaker Server and removed that. So Claris had to provide instructions to get your own php set up for custom web publishing in the Claris Engineering blog: https://support.claris.com/s/answerview?anum=000035470&language=en_US

These instructions were helpful, as were Tim Perfitt's instructions at Two Canoes for installing PHP on Monterey as he did for his MDS project: https://twocanoes.com/knowledge-base/installing-php-7-on-macos-12-monterey/

Of course, in Monterey you have to code-sign the PHP you install. But it is not so hard if you follow the method from Rich Trouton at "Der Flounder": https://derflounder.wordpress.com/2019/04/10/notarizing-automator-applications/

Using all this, I have had great success installing my own PHP on both my macOS FileMaker Server for custom PHP web publishing and my macOS Web Server (for a web site, munki server and munkireport server and various remote proxies. (both Macs on Monterey).

I presented on this topic along with my methodology including a "recipe" at the MacDevOps YVR conference 2022: https://www.youtube.com/watch?v=XzxxLHojXhk&t=1s

In short, PHP on the Mac still lives - but its up to the end user to maintain it.

This is simply frustrating. After wasting 3 hours of time I came to know that there is no php installed. ***! Apple. Why wouldn't you include php by default in a linux clone? Here is another dumb thing. I install and fix php in previous version only to be wiped out by next freaking update. ******* waste of my and thousands of other users. Apple sucks. Get it installed in next upgrade and leave us in peace.