0%

Mac安装Swoole扩展问题记录

[TOC]

openssl/ssl.h’ file not found`

/private/tmp/pear/temp/swoole/include/swoole.h:438:10: fatal error: 'openssl/ssl.h' file not found

原因:
openssl 未安装或 openssl 库不在标准位置中
解决方案:

  1. 确认是否安装了 openssl
    brew search openssl
    若未安装则执行命令brew install openssl进行安装

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

    1
    2
    ☁  ~ 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.2p/include/openssl/ /usr/local/include/

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

    但是,也可能会遇到很诡异的状况,上步没有解决问题,依然找不到 openssl/ssl.h 等文件
    复制 openssl 源文件到 swoole 的源码目录中,编译就可以了。

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

    这个肯定能解决问题了

Enable openssl support, require openssl library.

/private/tmp/pear/temp/swoole/php_swoole.h:137:2: error: "Enable openssl support, require openssl library."

上面的问题解决了,再次pecl install swoole时候报了这个错,找了很久都么有找到解决方案,偶然看到pecl 安装的过程:

1
2
3
4
5
6
7
8
9
enable debug/trace log support? [no] : yes
enable sockets supports? [no] : yes
enable openssl support? [no] : yes
enable http2 support? [no] : yes
enable async-redis support? [no] : yes
enable mysqlnd support? [no] : yes
enable postgresql coroutine client support? [no] : no
building in /private/tmp/pear/temp/pear-build-zhimmaSwGIQ1/swoole-4.2.1
running: /private/tmp/pear/temp/swoole/configure --with-php-config=/usr/local/opt/php@7.1/bin/php-config --enable-debug-log=yes --enable-sockets=yes --enable-openssl=yes --enable-http2=yes --enable-async-redis=yes --enable-mysqlnd=yes --enable-coroutine-postgresql=no

,于是猜想如果指定openssl的目录,是否可以解决,先看看openssl目录:

1
2
☁  ~  which openssl
/usr/local/opt/openssl/bin/openssl

于是安装过程就变成下面:

1
2
3
4
5
6
7
8
9
enable debug/trace log support? [no] : yes
enable sockets supports? [no] : yes
enable openssl support? [no] : yes --with-openssl-dir=/usr/local/opt/openssl/bin/openssl
enable http2 support? [no] : yes
enable async-redis support? [no] : yes
enable mysqlnd support? [no] : yes
enable postgresql coroutine client support? [no] : no
building in /private/tmp/pear/temp/pear-build-zhimmaN9CyFV/swoole-4.2.1
running: /private/tmp/pear/temp/swoole/configure --with-php-config=/usr/local/opt/php@7.1/bin/php-config --enable-debug-log=yes --enable-sockets=yes --enable-openssl=yes --with-openssl-dir=/usr/local/opt/openssl/bin/openssl --enable-http2=yes --enable-async-redis=yes --enable-mysqlnd=yes --enable-coroutine-postgresql=no

错误解决

Enable http2 support, require nghttp2 library.

/private/tmp/pear/temp/swoole/php_swoole.h:148:2: error: "Enable http2 support, require nghttp2 library.

解决方案:

brew install nghttp2

未能解决

hiredis/hiredis.h' file not found

/private/tmp/pear/temp/swoole/swoole_redis.c:20:10: fatal error: hiredis/hiredis.h' file not found

解决方案:

brew install hiredis

编译参数

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
--disable-option-checking  ignore unrecognized --enable/--with options
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-libdir=NAME Look for libraries in .../NAME rather than .../lib
--with-php-config=PATH Path to php-config php-config
--enable-swoole-debug Enable swoole debug
启用swoole的调试日志。不要在生产环境中启用此配置。
--enable-trace-log Enable swoole trace log
--enable-sockets Do you have sockets extension?
启用对 sockets 的支持。依赖 sockets
--enable-async-redis Do you have hiredis?
启用对异步Redis客户端的支持。依赖 hiredis
--enable-coroutine-postgresql Do you install postgresql?
启用协程 Postgresql 客户端,依赖 libpq
--enable-openssl Use openssl?
启用openssl支持。依赖 libssl.so
--enable-http2 Use http2.0?
启用HTTP2的支持。依赖 nghttp2
--enable-thread Experimental: Use thread?
启用线程支持 //实验性功能。请勿在生产环境中使用此功能
--enable-hugepage Experimental: Use hugepage?
启用 hugepage //使用大内存页优化性能,具体鸟哥在他的博客中讲到。
如果已经开启了 jemalloc,再开启hugepage 印象性能
https://blog.digitalocean.com/transparent-huge-pages-and-alternative-memory-allocators/
实验性功能。请勿在生产环境中使用此功能
--enable-swoole Enable swoole support
--enable-swoole-static Enable swoole static compile support
--with-swoole With swoole support
--with-libpq-dir=DIR Include libpq support (requires libpq >= 9.5)
--with-openssl-dir=DIR Include OpenSSL support (requires OpenSSL >= 0.9.6)
设置openssl库的路径,例如:--with-openssl-dir=/opt/openssl/.
--with-jemalloc-dir=DIR Include jemalloc support
使用 jemalloc 进行内存优化支持
--enable-mysqlnd Do you have mysqlnd?
启用对 mysqlnd 的支持,依赖 mysqlnd
--enable-coroutine Enable coroutine (requires PHP >= 5.5)
启用协程
--enable-asan Enable asan
启用 Address-Sanitizier 内存检测工具 //只有开启debug才有效
--enable-picohttpparser Experimental: Do you have picohttpparser?
启用 picohttpparser 支持 //这是一个超高性能的http解析器,实验性功能。请勿在生产环境中使用此功能
--enable-timewheel Experimental: Enable timewheel heartbeat?
启用时间轮算法并优化心跳算法 //实验性功能。请勿在生产环境中使用此功能
--enable-debug, compile with debug symbols
编译时加入符号表 //使用gdb调试时有用
--enable-shared=PKGS Build shared libraries default=yes
--enable-static=PKGS Build static libraries default=yes
--enable-fast-install=PKGS
Optimize for fast installation default=yes
--with-gnu-ld Assume the C compiler uses GNU ld default=no
--disable-libtool-lock Avoid locking (might break parallel builds)
--with-pic Try to use only PIC/non-PIC objects default=use both
--with-tags=TAGS Include additional configurations automatic

centos 安装swoole 扩展

__builtin_saddl_overflow

https://www.vpser.net/manage/centos-6-upgrade-gcc.html

__builtin_saddl_overflow’ was not declared in this scope
这是一个已知的问题 - 问题是 CentOS 上的默认 gcc 缺少必需的定义,即使在升级 gcc 之后,PECL 也会找到旧的编译器。要安装驱动程序,必须首先通过安装 devtoolset 集合来升级 gcc,如下所示:

  • sudo yum install centos-release-scl
  • sudo yum install devtoolset-7
  • scl enable devtoolset-7 bash