在macOS上更新XAMPP的PHP版本

I’m fairly new to mac and try to learn some things by playing around. Currently I’m trying to get an new PHP version on XAMPP running on my macbook. I've read different threads and tutorials for this (e.g. Is there way to use two PHP versions in XAMPP?) but I'm stuck. Here is what I got:

macOS Mojave with XAMPP 5.6.31-0 with PHP version 5.6.31

$ which PHP says /usr/bin/php

$ PHP -v says 7.1.19

So this means macOS has PHP7 out of the box? So I tried to make XAMPP load PHP7 from the mac path by editing the /xamppfiles/etc/httpd.conf by:

<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. Even if I delete the PHP 7 + 5 lines and expect PHP4 to be loaded it stays at 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. But for learning reasons I would like to get this done.

douqiao3930
douqiao3930 你为什么要这样做?macOS自带PHP7.1.19和Apache2.4.34。对于您可能需要做的任何本地开发来说,这已经足够了。
大约 2 年之前 回复
dowjgrm6787
dowjgrm6787 我本人根本不会使用XAMPP。通过自制软件安装PHP要容易得多。唯一剩下的就是每次都手动启动PHP服务器。但是,这可以从每个文件夹完成,因此root是动态的:-)。我有很多来自XAMPP的噩梦。这就是我使用自制软件版本的原因。
大约 2 年之前 回复

1个回答

The best way is install Homebrew, and then in your terminal, write this:

$ 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!

dongsechuan0535
dongsechuan0535 它实际上并没有修复
一年多之前 回复
doutuo7815
doutuo7815 谢谢你!,修好了
一年多之前 回复
doujugu1722
doujugu1722 一个小修复。 将$ brew update php更改为$ brew upgrade php
一年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐