[实践OK]Raspberry pi 的FreeBSD11系统下成功安装swoole扩展。及出现Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable. Then, rerun this script.

jackxiang 2016-2-21 13:10 | |
Raspberry Pi在FreeBSD下试图编译swoole扩展出现如下问题:
root@rpi2:~/software/swoole-src-swoole-1.8.1-stable # phpize
Configuring for:
PHP Api Version:         20131106
Zend Module Api No:      20131226
Zend Extension Api No:   220131226
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.

解决办法:
pkg install autoconf
pkg install m4

CentOS:
yum install m4 -y
yum install autoconf -y

重新编译:
root@rpi2:~/software/swoole-src-swoole-1.8.1-stable # phpize
root@rpi2:~/software/swoole-src-swoole-1.8.1-stable # ./configure
root@rpi2:~/software/swoole-src-swoole-1.8.1-stable # make && make install
/usr/local/include/php/ext/pcre/php_pcre.h:29:10: fatal error: 'pcre.h' file not found

其实这是由于缺少了pcre开发包所导致的,既然缺少那就装上吧:-),我是在Debian环境下当然想通过apt-get这个命令解决问题了,不过搜索了网络,只找到了CentOS的yum命令:
yum update
yum install pcre-devel
好吧,我只有依葫芦画瓢,把yum直接改成apt-get,不过apt-get install pcre-devel这步出错了,找不到包,仔细搜索了网络才知道,原来Debian系下不叫这个名字,正确的命令如下:
apt-get update
apt-get install libpcre3 libpcre3-dev
这样折腾一下,然后再pecl install apc一次,好了,成功安装了!
FreeBSD呢? 试一试:pkg install  pcre-devel  发现没有于是再度下:pkg install libpcre3 libpcre3-dev ,也没有。
看下pcre有没有最新,再看下:
root@rpi2:~/software/swoole-src-swoole-1.8.1-stable # pkg install pcre
Updating rpi repository catalogue...
rpi repository is up-to-date.
All repositories are up-to-date.
Checking integrity... done (0 conflicting)
The most recent version of packages are already installed
于是按:mac 10.10.3下安装Swoole扩展,提示pcre.h文件找不到:https://segmentfault.com/q/1010000002886696

正如@韩天峰 所说,你需要pcre扩展库文件,按照swoole的默认安装,程序会在/usr/local以及php include_path里面取搜索,事实上在安装pcre的时候你已经安装了这个库文件。

大概的位置/opt/local/include/pcre.h,所以你需要做一个软链
sudo ln -s /opt/local/include/pcre.h /usr/include/

如果没在这个位置你就搜索一下find / -name pcre,然后软链过去


真正实践OK的办法是:
./configure --with-php-config=/usr/local/bin/php-config  //这样也是不行的。
root@rpi2:/ # find . -name "pcre.h"
./usr/local/include/pcre.h
这行是关键:
ln -s /usr/local/include/pcre.h   /usr/include/pcre.h
就可以编译通过了,并生成了swoole.so,如下:
----------------------------------------------------------------------

Build complete.
Don't forget to run 'make test'.

Installing shared extensions:     /usr/local/lib/php/20131226-zts/
root@rpi2:~/software/swoole-src-swoole-1.8.1-stable # ls /usr/local/lib/php/20131226-zts/
swoole.so


root@rpi2:/usr/local/etc # cp php.ini-development php.ini
extension=swoole.so
root@rpi2:/usr/local/etc # php -m
[PHP Modules]
swoole

试一下程序:

httpServer.php: new file: 17 lines, 451 characters.
root@rpi2:~/php # php httpServer.php
[2016-02-18 06:46:50 @13407.0]  WARN    swSocket_set_buffer_size(:333): setsockopt(3, SOL_SOCKET, SO_SNDBUF, 8388608) failed. Error: No buffer space available[55].
[2016-02-18 06:46:50 @13407.0]  WARN    swSocket_set_buffer_size(:333): setsockopt(4, SOL_SOCKET, SO_SNDBUF, 8388608) failed. Error: No buffer space available[55].
[2016-02-18 06:46:50 @13407.0]  WARN    swSocket_set_buffer_size(:333): setsockopt(5, SOL_SOCKET, SO_SNDBUF, 8388608) failed. Error: No buffer space available[55].
[2016-02-18 06:46:50 @13407.0]  WARN    swSocket_set_buffer_size(:333): setsockopt(6, SOL_SOCKET, SO_SNDBUF, 8388608) failed. Error: No buffer space available[55].
[2016-02-18 06:46:50 @13407.0]  WARN    swSocket_set_buffer_size(:333): setsockopt(7, SOL_SOCKET, SO_SNDBUF, 8388608) failed. Error: No buffer space available[55].
[2016-02-18 06:46:50 @13407.0]  WARN    swSocket_set_buffer_size(:333): setsockopt(8, SOL_SOCKET, SO_SNDBUF, 8388608) failed. Error: No buffer space available[55].
[2016-02-18 06:46:50 @13407.0]  WARN    swSocket_set_buffer_size(:333): setsockopt(9, SOL_SOCKET, SO_SNDBUF, 8388608) failed. Error: No buffer space available[55].
[2016-02-18 06:46:50 @13407.0]  WARN    swSocket_set_buffer_size(:333): setsockopt(10, SOL_SOCKET, SO_SNDBUF, 8388608) failed. Error: No buffer space available[55].


root@rpi2:~/php # netstat
Active Internet connections
Proto Recv-Q Send-Q Local Address          Foreign Address        (state)
tcp4      78      0 localhost.9502         localhost.24050        CLOSE_WAI

root@rpi2:~/php # telnet localhost 9502
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.

root@rpi2:~/php # curl "http://127.0.0.1:9502"
出现:
php httpServer.php
[2016-02-18 06:55:17 #13407.0]  WARN    swServer_signal_hanlder: Fatal Error: manager process exit. status=0, signal=0.
[2016-02-18 06:55:23 $13408.0]  WARN    swManager_check_exit_status: worker#2 abnormal exit, status=0, signal=11
[2016-02-18 06:55:31 $13408.0]  WARN    swManager_check_exit_status: worker#1 abnormal exit, status=0, signal=11
[2016-02-18 06:55:38 $13408.0]  WARN    swManager_check_exit_status: worker#0 abnormal exit, status=0, signal=11
[2016-02-18 06:55:42 $13408.0]  WARN    swManager_check_exit_status: worker#2 abnormal exit, status=0, signal=11
——————————————缺少安装包来自———————————————————————
运行/usr/local/webserver/php/bin/phpize时出现:
Configuring for:
PHP Api Version:         20041225
Zend Module Api No:      20060613
Zend Extension Api No:   220060519
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.
根据网上的解决办法是:

# cd /usr/src
# wget http://ftp.gnu.org/gnu/m4/m4-1.4.9.tar.gz
# tar -zvxf m4-1.4.9.tar.gz
# cd m4-1.4.9/
# ./configure && make && make install
# cd ../
# wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.62.tar.gz
# tar -zvxf autoconf-2.62.tar.gz
# cd autoconf-2.62/
# ./configure && make && make install
更简单的办法
# yum install m4
# yum install autoconf

来自:http://blog.csdn.net/21aspnet/article/details/7471574


问题二:swoole error: use of undeclared identifier 'SIOCGIFHWADDR':
http://group.swoole.com/question/106871
替换:https://github.com/swoole/swoole-src/blob/9eaaf1382c7578933dac3fad143033d1bd8c085f/swoole.c

问题三:
https://github.com/swoole/swoole-src/issues/1347
swoole-src-1.9.19/src/network/Port.c:712:41: error: invalid operands to binary expression ('time_t'
      (aka 'long') and 'char *(*)(int, int)')
        if (date_format && mktime(&tm3) - timezone >= file_mtime)
                           ~~~~~~~~~~~~ ^ ~~~~~~~~
1 error generated.
*** Error code 1
修复:https://github.com/swoole/swoole-src/commit/607256a4b3796c1c0ade648379b50fdf815947a5
代码:https://github.com/swoole/swoole-src/blob/607256a4b3796c1c0ade648379b50fdf815947a5/src/network/Port.c

编译成功@11.1-RELEASE FreeBSD 11.1-RELEASE:
creating ./swoole.la
(cd ./.libs && rm -f swoole.la && ln -s ../swoole.la swoole.la)
/bin/sh /tmp/swoole-src-1.9.19/libtool --mode=install cp ./swoole.la /tmp/swoole-src-1.9.19/modules
cp ./.libs/swoole.so /tmp/swoole-src-1.9.19/modules/swoole.so
cp ./.libs/swoole.lai /tmp/swoole-src-1.9.19/modules/swoole.la


php -i | grep extension
extension_dir => /usr/local/php/ext/ => /usr/local/php/ext/
cp -rf /tmp/swoole-src-1.9.19/modules/swoole.so /usr/local/php/ext/
vi /usr/local/etc/php.ini
extension=swoole.so

作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:http://jackxiang.com/post/8523/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!


最后编辑: jackxiang 编辑于2022-5-31 16:10
评论列表
发表评论

昵称

网址

电邮

打开HTML 打开UBB 打开表情 隐藏 记住我 [登入] [注册]