Ubuntu环境下php安装swoole扩展

31 篇文章 1 订阅
1.下载swoole源码包

https://github.com/swoole/swoole-src/releases
http://pecl.php.net/package/swoole

http://git.oschina.net/swoole/swoole

2.编译安装

使用phpize来生成php编译配置

./configure 来做编译配置检测

make进行编译,make install进行安装

ming@ming-TM1604:/opt/swoole-2.1.1$ ls
package.xml  swoole-2.1.1
ming@ming-TM1604:/opt/swoole-2.1.1$ cd swoole-2.1.1/
ming@ming-TM1604:/opt/swoole-2.1.1/swoole-2.1.1$ phpize 
Configuring for:
PHP Api Version:         20160303
Zend Module Api No:      20160303
Zend Extension Api No:   320160303
ming@ming-TM1604:/opt/swoole-2.1.1/swoole-2.1.1$ ./configure --with-php-config=/usr/local/php/bin/php-config 

./configure 后面为php的配置环境位置,配置检测完成进行编译

creating libtool
appending configuration tag "CXX" to libtool
configure: creating ./config.status
config.status: creating config.h
ming@ming-TM1604:/opt/swoole-2.1.1/swoole-2.1.1$ sudo make

编译完成会提示生成的swoole.so的位置/opt/swoole-2.1.1/swoole-2.1.1/modules/swoole.so,安装

cp ./.libs/swoole.so /opt/swoole-2.1.1/swoole-2.1.1/modules/swoole.so
cp ./.libs/swoole.lai /opt/swoole-2.1.1/swoole-2.1.1/modules/swoole.la
PATH="$PATH:/sbin" ldconfig -n /opt/swoole-2.1.1/swoole-2.1.1/modules
----------------------------------------------------------------------
Libraries have been installed in:
   /opt/swoole-2.1.1/swoole-2.1.1/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

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

ming@ming-TM1604:/opt/swoole-2.1.1/swoole-2.1.1$ sudo make install
Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20160303/
Installing header files:          /usr/local/php/include/php/
ming@ming-TM1604:/opt/swoole-2.1.1/swoole-2.1.1$ 
3.swoole.so扩展到php.ini中
extension=/opt/swoole-2.1.1/swoole-2.1.1/modules/swoole.so
4.重启服务器和php-fpm,运行php -m可查看安装的模块是否含有swoole
ming@ming-TM1604:/opt/swoole-2.1.1$ sudo service nginx restart 
ming@ming-TM1604:/opt/swoole-2.1.1$ sudo service php-fpm restart 
ming@ming-TM1604:/opt/swoole-2.1.1$ php -m
[PHP Modules]
bcmath
Core
ctype
curl
date
dom
filter
ftp
gd
gettext
hash
iconv
intl
json
libxml
mbstring
mcrypt
mongodb
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_pgsql
pdo_sqlite
Phar
posix
Reflection
session
shmop
SimpleXML
soap
sockets
SPL
sqlite3
standard
swoole
sysvsem
tokenizer
xml
xmlreader
xmlrpc
xmlwriter
xsl
zip
zlib

[Zend Modules]

ming@ming-TM1604:/opt/swoole-2.1.1$ 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值