简体   繁体   English

在 macOS 上更新 XAMPP 的 PHP 版本

[英]Update PHP Version of XAMPP on macOS

I'm fairly new to mac and try to learn some things by playing around.我对 mac 相当陌生,并尝试通过玩耍来学习一些东西。 Currently I'm trying to get an new PHP version on XAMPP running on my macbook.目前我正在尝试在我的 macbook 上运行的 XAMPP 上获得一个新的 PHP 版本。 I've read different threads and tutorials for this (eg Is there way to use two PHP versions in XAMPP? ) but I'm stuck.我已经为此阅读了不同的线程和教程(例如, 有没有办法在 XAMPP 中使用两个 PHP 版本? )但我被卡住了。 Here is what I got:这是我得到的:

macOS Mojave with XAMPP 5.6.31-0 with PHP version 5.6.31 macOS Mojave 与 XAMPP 5.6.31-0 与 PHP 版本 5.6.31

$ which PHP says /usr/bin/php $ which PHP/usr/bin/php

$ PHP -v says 7.1.19 $ PHP -v表示7.1.19

So this means macOS has PHP7 out of the box?所以这意味着 macOS 具有开箱即用的 PHP7 吗? So I tried to make XAMPP load PHP7 from the mac path by editing the /xamppfiles/etc/httpd.conf by:因此,我尝试通过以下方式编辑/xamppfiles/etc/httpd.conf使 XAMPP 从 mac 路径加载 PHP7:

<IfDefine JUSTTOMAKEAPXSHAPPY>
#LoadModule php4_module        modules/libphp4.so
#LoadModule php5_module        modules/libphp5.so
LoadModule php7_module         /usr/libexec/apache2/libphp7.so
</IfDefine>

But after restarting the apache phpinfo() stays hat 5.6.31 .但是在重新启动 apache phpinfo()仍然是 hat 5.6.31 Even if I delete the PHP 7 + 5 lines and expect PHP4 to be loaded it stays at 5.即使我删除了 PHP 7 + 5 行并期望加载 PHP4,它也会保持在 5。

So what am I doing wrong?那么我做错了什么?

Disclaimer: I know it would be the easiest way to download a newer XAMPP version or use the build in apache from mac.免责声明:我知道这将是下载更新的 XAMPP 版本或使用 mac 中的 apache 构建的最简单方法。 But for learning reasons I would like to get this done.但出于学习原因,我想完成这项工作。

The best way is install Homebrew, and then in your terminal, write this:最好的方法是安装 Homebrew,然后在你的终端中,写下:

$ brew upgrade php // upgrade php formula
$ brew install php@7.2
$ brew link php@7.2 // create an alias to this keg-only version; see comments output during installation
$ echo 'export PATH="/usr/local/opt/php@7.2/bin:$PATH"' >> ~/.bash_profile // add the alias to your path; see comments output during installation
$ source ~/.bash_profile // reload .bash_profile to use the new settings immediately

greetings!你好!

After a lot of research and implementation, the best one that works for me without using the homebrew command this经过大量研究和实施,最好的一个不使用自制命令对我有用

  • go to this link https://php-osx.liip.ch/#install转到此链接https://php-osx.liip.ch/#install
  • copy the url of the php version you want to install复制你要安装的php版本的url
  • paste it inside your terminal, it will require for your password, kindly provide it将其粘贴到您的终端中,它将需要您的密码,请提供
  • After installation is complete, add the default path of php to your bash profile by doing this export PATH=/usr/local/php5/bin:$PATH you can simply copy and paste, after check your php version.安装完成后,通过执行此export PATH=/usr/local/php5/bin:$PATH将 php 的默认路径添加到您的 bash 配置文件中,您可以在检查您的 php 版本后简单地复制和粘贴。 i believe it will have change.我相信它会有变化。

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

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