Swoole在Mac系统编译时遇到错误该如何解决?

2026-04-28 23:124阅读0评论SEO资源
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计850个文字,预计阅读时间需要4分钟。

Swoole在Mac系统编译时遇到错误该如何解决?

在使用Swoole进行MAC编译时遇到错误,可以尝试以下步骤解决:

Swoole在Mac系统编译时遇到错误该如何解决?

1. 首先,确保已经完整阅读了官方文档,理解了安装步骤。

2.使用pecl安装Swoole扩展(注意,你可能需要手动安装依赖):

pecl install swoole 如果遇到问题,可能需要手动安装Swoole的依赖库。

3.如果你是在2018年4月之前安装的,由于Homebrew的变动,可能无法使用`brew install`安装PHP。这时,你可能需要手动下载PHP源码编译安装,确保安装了Swoole支持的PHP版本。

swoole mac编译错误怎么办?mac 安装 swoole 可能会出现的错误

请先看完之后再操作

一、用pecl安装swoole(没有安装起来)

2018年4月,由于homebrew的变动,导致无法使用brew install的方式安装php的扩展,现在改为用pecl安装,pecl安装swoole的方法为:

pecl install swoole

出现在选项要填yes还是no

可能出现的报错及解决方法

1 fatal error: ‘openssl/ssl.h‘ file not found

解决方法1:cp -R /usr/local/opt/openssl/include/openssl /usr/local/include

解决方法2:ln -s /usr/local/opt/openssl/include/openssl /usr/local/include/openssl

原因:一般用brew安装的软件,都会把需要include的文件自动放到/usr/local/include里的,但是不知为什么安装openssl的时候没有放到那里,所以要自己拷过去,其实最好的方法是做一个链接,即用解决方法2!

2 error: Cannot find libpq-fe.h. Please confirm the libpq or specify correct PostgreSQL(libpq) installation path

解决方法 brew reinstall PostgreSQL

原因:可能是没有安装PostgreSQL

3 fatal error: ‘hiredis/hiredis.h‘ file not found

出现这个原因绝大多数是因为没有安装hiredis,用brew search hiredis看看有没安装,没有安装直接用brew install hiredis安装后,再次pecl install swoole就可以

细心的童鞋会发现,brew install hiredis后,/usr/local/include里,多了一个hiredis,而且这个是一个软链,链接到/usr/local/Cellar/hiredis/0.13.3/include/hiredis

结果还是报错,没有搞定,能力有限.

二、换了个方式 安装swoole(完美解决)

2.1 下载swoole

sudo pecl download swoole

2.2 编译安装

tar zxvf swoole-4.2.12.tgz // 注意自己下载的版本,可能不一定 cd swoole-4.2.12 phpize ./configure --enable-openssl --enable-http2 --enable-sockets --enable-mysqlnd -with-openssl-dir=/usr/local/Cellar/openssl/1.0.2s/ make clean && make && sudo make install

2.3 遇到报错

mkdir: /usr/local/Cellar/php@7.1/7.1.30/pecl: File exists mkdir: /usr/local/Cellar/php@7.1/7.1.30/pecl: No such file or directory make: *** [install-modules] Error 1 // 大致意思就是 pecl 文件夹存在,但是打不开 // 我的pecl是软连接过来的 不知道为什么打不开

2.4 解决方法

修改 /usr/local/Cellar/php@7.1/7.1.30/bin/php-config

extension_dir=‘/usr/local/Cellar/php@7.1/7.1.30/pecl/20160303‘ 中的 『pecl』 换成 『lib/php』 extension_dir=‘/usr/local/Cellar/php@7.1/7.1.30/lib/php/20160303‘

2.5 重新编译

./configure --enable-openssl --enable-http2 --enable-sockets --enable-mysqlnd -with-openssl-dir=/usr/local/Cellar/openssl/1.0.2s/ make clean && make && sudo make install

2.6 添加 swoole.so

修改php.ini 在文件末尾 加一行

extension = "/usr/local/Cellar/php@7.1/7.1.30/lib/php/20160303/swoole.so"

mac安装swoole 真是疼

以上就是swoole mac编译错误怎么办的详细内容,更多请关注自由互联其它相关文章!

本文共计850个文字,预计阅读时间需要4分钟。

Swoole在Mac系统编译时遇到错误该如何解决?

在使用Swoole进行MAC编译时遇到错误,可以尝试以下步骤解决:

Swoole在Mac系统编译时遇到错误该如何解决?

1. 首先,确保已经完整阅读了官方文档,理解了安装步骤。

2.使用pecl安装Swoole扩展(注意,你可能需要手动安装依赖):

pecl install swoole 如果遇到问题,可能需要手动安装Swoole的依赖库。

3.如果你是在2018年4月之前安装的,由于Homebrew的变动,可能无法使用`brew install`安装PHP。这时,你可能需要手动下载PHP源码编译安装,确保安装了Swoole支持的PHP版本。

swoole mac编译错误怎么办?mac 安装 swoole 可能会出现的错误

请先看完之后再操作

一、用pecl安装swoole(没有安装起来)

2018年4月,由于homebrew的变动,导致无法使用brew install的方式安装php的扩展,现在改为用pecl安装,pecl安装swoole的方法为:

pecl install swoole

出现在选项要填yes还是no

可能出现的报错及解决方法

1 fatal error: ‘openssl/ssl.h‘ file not found

解决方法1:cp -R /usr/local/opt/openssl/include/openssl /usr/local/include

解决方法2:ln -s /usr/local/opt/openssl/include/openssl /usr/local/include/openssl

原因:一般用brew安装的软件,都会把需要include的文件自动放到/usr/local/include里的,但是不知为什么安装openssl的时候没有放到那里,所以要自己拷过去,其实最好的方法是做一个链接,即用解决方法2!

2 error: Cannot find libpq-fe.h. Please confirm the libpq or specify correct PostgreSQL(libpq) installation path

解决方法 brew reinstall PostgreSQL

原因:可能是没有安装PostgreSQL

3 fatal error: ‘hiredis/hiredis.h‘ file not found

出现这个原因绝大多数是因为没有安装hiredis,用brew search hiredis看看有没安装,没有安装直接用brew install hiredis安装后,再次pecl install swoole就可以

细心的童鞋会发现,brew install hiredis后,/usr/local/include里,多了一个hiredis,而且这个是一个软链,链接到/usr/local/Cellar/hiredis/0.13.3/include/hiredis

结果还是报错,没有搞定,能力有限.

二、换了个方式 安装swoole(完美解决)

2.1 下载swoole

sudo pecl download swoole

2.2 编译安装

tar zxvf swoole-4.2.12.tgz // 注意自己下载的版本,可能不一定 cd swoole-4.2.12 phpize ./configure --enable-openssl --enable-http2 --enable-sockets --enable-mysqlnd -with-openssl-dir=/usr/local/Cellar/openssl/1.0.2s/ make clean && make && sudo make install

2.3 遇到报错

mkdir: /usr/local/Cellar/php@7.1/7.1.30/pecl: File exists mkdir: /usr/local/Cellar/php@7.1/7.1.30/pecl: No such file or directory make: *** [install-modules] Error 1 // 大致意思就是 pecl 文件夹存在,但是打不开 // 我的pecl是软连接过来的 不知道为什么打不开

2.4 解决方法

修改 /usr/local/Cellar/php@7.1/7.1.30/bin/php-config

extension_dir=‘/usr/local/Cellar/php@7.1/7.1.30/pecl/20160303‘ 中的 『pecl』 换成 『lib/php』 extension_dir=‘/usr/local/Cellar/php@7.1/7.1.30/lib/php/20160303‘

2.5 重新编译

./configure --enable-openssl --enable-http2 --enable-sockets --enable-mysqlnd -with-openssl-dir=/usr/local/Cellar/openssl/1.0.2s/ make clean && make && sudo make install

2.6 添加 swoole.so

修改php.ini 在文件末尾 加一行

extension = "/usr/local/Cellar/php@7.1/7.1.30/lib/php/20160303/swoole.so"

mac安装swoole 真是疼

以上就是swoole mac编译错误怎么办的详细内容,更多请关注自由互联其它相关文章!