brew link php56报错,在 Mac下安装 Swoole 和 SwooleDistributed 3.X 出现的问题整理

司马祖鹤
2023-12-01

phpize运行报错

grep: /usr/include/php/main/php.h: No such file or directory

grep: /usr/include/php/Zend/zend_modules.h: No such file or directory

grep: /usr/include/php/Zend/zend_extensions.h: No such file or directory

Configuring for:

PHP Api Version:

Zend Module Api No:

Zend Extension Api No:

原因:

文件在这个目录下:

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include

编译Swoole报错:

swoole.h:414:10: fatal error: 'openssl/ssl.h' file not found

#include

原因:

openssl 未安装或 openssl 库不在标准位置中

解决方案:

1、确认是否安装了 openssl

brew search openssl

若未安装则执行命令brew install openssl进行安装

2、确认 openssl 库是否在标准位置中

ls /usr/local/include/openssl

No such file or directory

这就是问题所在了,找到 openssl/include/openssl 目录,并 cp 到 /usr/local/include 目录中。

ln -s /usr/local/Cellar/openssl/1.0.2o_1/include/openssl /usr/local/include/

一般情况下就可以解决该问题了。

但是,也可能会遇到很诡异的状况,上步没有解决问题,依然找不到 openssl/ssl.h 等文件

复制 openssl 源文件到 swoole 的源码目录中,编译就可以了。

cp -R /usr/local/Cellar/openssl/1.0.2o_1/include/openssl swoole-src-2.1.3/include

安装php72-redis扩展

➜ ~ brew search php72-redis

==> Searching local taps...

==> Searching taps on GitHub...

==> Searching blacklisted, migrated and deleted formulae...

No formula found for "php72-redis".

Closed pull requests:

Bump revision for php72-redis (https://github.com/Homebrew/homebrew-php/pull/4428)

php72-redis 3.1.2 (new formula) (https://github.com/Homebrew/homebrew-php/pull/4257)

enchant 2.2.0 (https://github.com/Homebrew/homebrew-core/pull/21807)

Add PHP 7.2.0-alpha.1 core formula (php72) (https://github.com/Homebrew/homebrew-php/pull/4211)

➜ ~ brew install php72-redis

Updating Homebrew...

==> Auto-updated Homebrew!

安装 hiredis 扩展

➜ ~ brew install hiredis

Updating Homebrew...

==> Auto-updated Homebrew!

Updated 1 tap (caskroom/cask).

No changes to formulae.

==> Downloading https://homebrew.bintray.com/bottles/hiredis-0.13.3.high_sierra.bottle.tar.gz

######################################################################## 100.0%

==> Pouring hiredis-0.13.3.high_sierra.bottle.tar.gz

/usr/local/Cellar/hiredis/0.13.3: 31 files, 189.4KB

安装 redis 和设置开机启动

brew install redis

# 开机启动redis命令

ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents

回退Mac上用Brew安装的PHP版本

brew list

brew unlink php56

brew link php55

 类似资料: