前提,因为想要支持medoo2.1,此插件最新低支持php7.3,原本只打算升级到7.3但是brew下载报错,索性直接升级到7.4
注意:brew会自动更新很多包
所以我们要先限制一下
vim ~/.bash_profile
# 新增一行
#限制自动更新
export HOMEBREW_NO_AUTO_UPDATE=true
#限制升级包的时候自动升级家属
export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=true
生效配置 source ~/.bash_profile
使用brew下载 brew install php@7.4
==> Caveats
To enable PHP in Apache add the following to httpd.conf and restart Apache:
LoadModule php7_module /usr/local/opt/php@7.4/lib/httpd/modules/libphp7.so<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>Finally, check DirectoryIndex includes index.php
DirectoryIndex index.php index.htmlThe php.ini and php-fpm.ini file can be found in:
/usr/local/etc/php/7.4/php@7.4 is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.If you need to have php@7.4 first in your PATH, run:
echo 'export PATH="/usr/local/opt/php@7.4/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/usr/local/opt/php@7.4/sbin:$PATH"' >> ~/.zshrcFor compilers to find php@7.4 you may need to set:
export LDFLAGS="-L/usr/local/opt/php@7.4/lib"
export CPPFLAGS="-I/usr/local/opt/php@7.4/include"
To restart php@7.4 after an upgrade:
brew services restart php@7.4
Or, if you don't want/need a background service you can just run:
/usr/local/opt/php@7.4/sbin/php-fpm --nodaemonize
==> Summary
安装扩展:
使用pecl 安装扩展
进入到指定版本的php目录下,cp /usr/local/Cellar/php@7.4/7.4.26_1 运行:
pecl install redis