Swoole学习之Swoole源码安装(二)
一、swoole源码下载
Swoole官网下载:https://www.swoole.com/,我们用源代码(开源中国) 库下载:
这里用git直接将源代码包克隆到本地
root@5ee6bfcc1310:/work/study/softpackage# git clone [email protected]:swoole/swoole.git
或者直接用curl直接下载,然后解压缩包:
curl https://gitee.com/swoole/swoole/repository/archive/master.zip
二、swoole源码安装
swoole和php的源码安装基本一样,但是 swoole 没有 configure
安装文件,这就需要我们使用PHP自带的工具 phpize
(phpize用来添加扩展模块的,可以建立PHP的外挂模块) 来生成这样的文件。
进入 swoole源码包目录下,然后执行/work/study/soft/php/bin/phpize
命令:
swoole# /work/study/soft/php/bin/phpize Configuring for: PHP Api Version: 20170718 Zend Module Api No: 20170718 Zend Extension Api No: 320170718
这时我们查看swoole源码包,会生成多个文件,其中就有 configure
文件。
编译:
swoole# ./configure --with-php-config=/work/study/soft/php/bin/php-config swoole# make && make install
--with
表示指定安装的php版本,如果系统中有多个php版本的话,需要指定
编译结果:
... PATH="$PATH:/sbin" ldconfig -n /work/study/softpackage/swoole/modules ---------------------------------------------------------------------- Libraries have been installed in: /work/study/softpackage/swoole/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'. Installing shared extensions: /work/study/soft/php/lib/php/extensions/no-debug-non-zts-20170718/ Installing header files: /work/study/soft/php/include/php/ root@5ee6bfcc1310:/work/study/softpackage/swoole#
扩展放在了 /work/study/soft/php/lib/php/extensions/no-debug-non-zts-20170718/
目录下了,我们查看该目录:
root@5ee6bfcc1310:/work/study/soft/php/bin# cd /work/study/soft/php/lib/php/extensions/no-debug-non-zts-20170718/ root@5ee6bfcc1310:/work/study/soft/php/lib/php/extensions/no-debug-non-zts-20170718# ls -l total 21820 -rwxr-xr-x 1 root root 5227454 Aug 27 18:07 opcache.a -rwxr-xr-x 1 root root 2413144 Aug 27 18:07 opcache.so -rwxr-xr-x 1 root root 14696248 Aug 28 11:06 swoole.so
swoole.so
这个文件就是我们编译后的扩展文件。
三、PHP支持Swoole
php如果要使用扩展类库,必须在 php.ini
文件中做一些配置才能使用,否则会报错找不到该类文件。
编辑php.ini
文件
root@5ee6bfcc1310:/work/study/soft/php/lib# vim php.ini
extension 扩展新增一行:
extension=swoole
检查一下,是否有swoole扩展:
root@5ee6bfcc1310:/work/study/soft/php/lib# php -m [PHP Modules] Core ctype date dom fileinfo filter hash iconv json libxml pcre PDO pdo_sqlite Phar posix Reflection session SimpleXML SPL sqlite3 standard swoole tokenizer xml xmlreader xmlwriter [Zend Modules]
我们可以看到PHP的扩展已经有 swoole,至此,我们的PHP和Swoole安装编译完成 ^_^。
相关推荐
ChinaJoeEE 2020-08-16
瓜牛呱呱 2020-11-12
柳木木的IT 2020-11-04
yifouhu 2020-11-02
lei0 2020-11-02
源码zanqunet 2020-10-28
源码zanqunet 2020-10-26
一叶梧桐 2020-10-14
码代码的陈同学 2020-10-14
lukezhong 2020-10-14
lzzyok 2020-10-10
anchongnanzi 2020-09-21
clh0 2020-09-18
changcongying 2020-09-17
星辰大海的路上 2020-09-13
abfdada 2020-08-26
mzy000 2020-08-24
shenlanse 2020-08-18