mac 安装php 及插件redis swoole

本文详细介绍如何在Mac上使用Homebrew安装配置PHP及相关组件如Nginx、Redis和MySQL等,解决安装过程中可能遇到的问题,并设置环境变量,最后安装PHP扩展如pecl和swoole。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

安装php相关环境(brew安装请参考:https://blog.youkuaiyun.com/wangzhufei/article/details/109045788

brew install nginx

brew install redis

brew install mysql@5.7

brew install php@7.4(不写参数则安装最新的)

注1:如果权限问题加sudo

注2:启动和操作  brew services start|restart|stop 软件名

安装php报问题处理  

问题一:

And make sure that your user has write permission.
  chmod u+w /usr/local/lib/pkgconfig

处理:sudo chmod 777 /usr/local/lib/pkgconfig

问题二:

Error: The following formula
  [#<Dependency: "python@3.9" []>, #<Options: []>]
cannot be installed as binary package and must be built from source.
Install the Command Line Tools:
  xcode-select --install

处理:   在app store安装 xcode

 

设置环境变量(brew安装的都在/usr/local/Cellar 目录下)

    sudo vim ~/.bash_profile
    添加:
        export PATH="/usr/local/Cellar/php/7.4.11/bin:$PATH"    (给php命令使用)
        export PATH="/usr/local/Cellar/php/7.4.11/sbin:$PATH"     (给php-fpm命令使用)
    保存

    sudo vim ~/.zshrc
    添加:source ~/.bash_profile
    保存
    source ~/.zshrc

安装php插件 pecl和swoole(用以下链接)

https://blog.youkuaiyun.com/wangzhufei/article/details/109066565

安装php插件 redis(用以下链接)

https://blog.youkuaiyun.com/wangzhufei/article/details/109069046

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值