简体   繁体   中英

PHP CLI on Apple M1 using Homebrew

I've followed this guide to install Homebrew on an M1 based Mac.

After that I ran

brew install php@7.4

which installed PHP successfully.

If I now run

brew upgrade php

I get

Error: php not installed

What I like to achieve is to update the PHP that comes shipped with macOS, which is 7.3.22 when I run php -v .

How can I update PHP using Homebrew? I understood that I need to put something in my PATH to point to the newer PHP version? Given this is a new machine I actually don't have a .bash_profile file, only a .zshrc (I'm using ZSH, I assume that this file will be used and that I don't need a .bash_profile ?)

It's not advisable to upgrade the system-provided PHP, but it's also not necessary.

brew link can be used to decide which PHP is utilized. brew link php@7.4 should do the trick; this can be also used to switch PHP versions around, ie brew link php@8.0 will switch you over to that while leaving both versions installed and available directly.

use ampps instead of xampp. in ampps setting you can change the version accordingly without any trouble.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM