简体   繁体   English

无法使用 MacPorts 更新最新版本的 PHP

[英]Can't update latest version of PHP using MacPorts

I have tried using MacPorts to update to the latest version of PHP.我尝试使用 MacPorts 更新到最新版本的 PHP。 After typing sudo port install php and installing all the necessary packages, when I type php --version in the terminal, I still get:输入sudo port install php并安装所有必要的软件包后,当我在终端输入php --version时,我仍然得到:

PHP 7.3.29 (cli) (built: Aug 15 2021 23:10:16) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.29, Copyright (c) 1998-2018 Zend Technologies

Why does my computer still have an outdated version of PHP instead of PHP 8?为什么我的电脑上仍然有一个过时的 PHP 版本而不是 PHP 8?

The php port in MacPorts is a shim, it only installs the /opt/local/share/doc/php/README file and depends on (currently) php82 . MacPorts 中的php端口是一个垫片,它只安装/opt/local/share/doc/php/README文件并依赖于(当前) php82 Click one of the Files links on https://ports.macports.org/port/php/details/ to see that.单击https://ports.macports.org/port/php/details/上的文件链接之一以查看它。

What gets run when you type php --version in your shell depends on the symlink /opt/local/bin/php , but that symlink is managed by the port select mechanism explained in the port-select(1) manpage :当您在 shell 中键入php --version时运行的内容取决于符号链接/opt/local/bin/php ,但该符号链接由port-select(1) 联机帮助页中解释的端口选择机制管理:

port select provides a mechanism to choose from different implementations of a common tool or port. port select 提供了一种从通用工具或端口的不同实现中进行选择的机制。 Selecting one of the options makes it the primary version or implementation, eg the one to be run by default when you do not explicitly select a version or implementation on the command line.选择其中一个选项使其成为主要版本或实现,例如当您未在命令行上明确选择版本或实现时默认运行的那个。

Note that port select is only for your convenience as user.请注意,端口选择只是为了您作为用户的方便。 It does not, for example, affect which compiler MacPorts uses when it compiles software, or against which copy of MySQL a port builds.例如,它不会影响 MacPorts 在编译软件时使用的编译器,或者端口构建的 MySQL 副本。 If there is a user-visible choice, it is usually offered as a variant on the port.如果有用户可见的选择,它通常作为端口的变体提供。 If the port select mechanism affects how a port builds, that should be considered a bug.如果端口选择机制影响端口的构建方式,则应将其视为错误。

One example is the set of MySQL and forks of MySQL, where there are mysql51, mysql55, mysql56, mariadb, mariadb-10.0, mariadb-11.0, percona, possibly among others.一个例子是 MySQL 的集合和 MySQL 的分支,其中可能有 mysql51、mysql55、mysql56、mariadb、mariadb-10.0、mariadb-11.0、percona 等。 port select lets you choose which of these becomes the version run, when you simply run mysql or other commands from the MySQL suite.当您简单地运行 mysql 或 MySQL 套件中的其他命令时,port select 允许您选择其中哪个成为运行的版本。

In your case, you have probably previously used sudo port select --set php php73 .在您的情况下,您可能以前使用过sudo port select --set php php73 To make PHP 8.2 your default, run sudo port select --set php php82 .要将 PHP 8.2 设置为默认值,请运行sudo port select --set php php82 Run port select --summary to see the currently selected option.运行port select --summary以查看当前选择的选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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