【问题标题】:Change CLI PHP version on Mac在 Mac 上更改 CLI PHP 版本
【发布时间】:2021-10-05 13:13:45
【问题描述】:

我使用 Mac BigSur 最新更新。 我已经用 PHP 8.0.8 版安装了 Bitnami MAPP。 但在 CLI 中仍然是 PHP 7.3.24

我尝试创建到 Bitnami PHP8.0.8 的路径,但有如下警告

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: Dec 21 2020 21:33:25) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.24, Copyright (c) 1998-2018 Zend Technologies

PHP CLI如何切换到Bitnami的PHP8.0.8?

【问题讨论】:

    标签: php macos bitnami


    【解决方案1】:

    Bitnami 工程师在这里!

    您看到的输出是由 macOS 中预装的 PHP 二进制文件生成的。当您安装 Bitnami MAMP 时,一个独立的、更新的 PHP 版本也将安装在您的系统中。为了使用它而不是默认的,您有两种选择:

    1. 使用二进制文件的完整路径 (installdir/php/bin/php)
    $ /Applications/mampstack-8.0.9-0/php/bin/php --version
    PHP 8.0.9 (cli) (built: Jul 30 2021 07:59:45) ( NTS )
    Copyright (c) The PHP Group
    Zend Engine v4.0.9, Copyright (c) Zend Technologies
        with Zend OPcache v8.0.9, Copyright (c), by Zend Technologies
    
    1. 将包含 PHP 二进制文件的目录添加到您的路径中
    $ export PATH=/Applications/mampstack-8.0.9-0/php/bin:$PATH
    $php --version
    PHP 8.0.9 (cli) (built: Jul 30 2021 07:59:45) ( NTS )
    Copyright (c) The PHP Group
    Zend Engine v4.0.9, Copyright (c) Zend Technologies
        with Zend OPcache v8.0.9, Copyright (c), by Zend Technologies
    

    对于上面的示例,/Applications/mampstack-8.0.9-0 是堆栈的安装目录 (installdir)。

    【讨论】:

    • 谢谢@Jose。是的,which php 命令帮助我了解哪个 php 引擎在 CLI 模式下工作。然后将其切换到正确的。
    猜你喜欢
    • 2019-07-31
    • 2021-02-17
    • 2017-08-19
    • 2019-09-10
    • 2017-06-11
    • 1970-01-01
    • 2018-12-09
    • 1970-01-01
    相关资源
    最近更新 更多