简体   繁体   English

使用 Homebrew MacOS Monterey 的 PHP 版本与 CLI 版本不同

[英]PHP version different to CLI version using Homebrew MacOS Monterey

I have installed PHP with homebrew, switch to PHP 8.0 but the browser phpinfo() is showing 7.4.我已经用 homebrew 安装了 PHP,切换到 PHP 8.0 但浏览器 phpinfo() 显示 7.4。 I am on the latest version of Monterey.我正在使用最新版本的蒙特雷。

brew services stop httpd is stopping the apache service. brew services stop httpd正在停止 apache 服务。

% php -v
PHP 8.0.19 (cli) (built: May 12 2022 02:25:19) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.19, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.19, Copyright (c), by Zend Technologies
% which php
/opt/homebrew/bin/php

How would I get PHP 8.0 to work in the browser?如何让 PHP 8.0 在浏览器中工作?

in your httpd config, you must hardwire the shipped php version (7.4), with apache, would look like this :在您的 httpd 配置中,您必须使用 apache 硬连线随附的 php 版本 (7.4),如下所示:

LoadModule php7_module /usr/local/opt/php@7.4/lib/httpd/modules/libphp7.so  

Just change the httpd config to load the appropriate lib, and restart your httpd server.只需更改 httpd 配置以加载适当的库,然后重新启动您的 httpd 服务器。 Also, php has multiple configs (cli, fpm) : make certain that you tailor the appropriate one in your configs , typically found in /usr/local/etc/php/8.N (monterey, brewed-in php)此外,php 有多个配置(cli、fpm):确保在配置中定制适当的配置,通常在 /usr/local/etc/php/8.N 中找到(monterey,brewed-in php)

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

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