首先找到phpize的位置,一般在安装目录的bin目录中
在swoole文件夹中执行phpize
season@ubuntu:~/Downloads/swoole$ /usr/local/php/bin/phpize
Configuring for:
PHP Api Version: 20170718
Zend Module Api No: 20170718
Zend Extension Api No: 320170718
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.
tips:
如果出现:$PHP_AUTOCONF environment variable. Then, rerun this script.
就要去装autoconf
ubuntu:~/Downloads/swoole$ sudo apt install autoconf
再次执行phpzie
season@ubuntu:~/Downloads/swoole$ /usr/local/php/bin/phpize
Configuring for:
PHP Api Version: 20170718
Zend Module Api No: 20170718
Zend Extension Api No: 320170718
如果出现configure文件,那就说明ok啦。
继续操作:
season@ubuntu:~/Downloads/swoole$ ./configure --with-php-config=/usr/local/php/bin/php-config
season@ubuntu:~/Downloads/swoole$ make
season@ubuntu:~/Downloads/swoole$ sudo make install
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20170718/
Installing header files: /usr/local/php/include/php/
查看没有swoole.so扩展
season@ubuntu:/usr/local/php/lib/php/extensions/no-debug-non-zts-20170718$ ll
总用量 10424
drwxr-xr-x 2 root root 4096 3月 31 13:23 ./
drwxr-xr-x 3 root root 4096 3月 31 12:42 ../
-rwxr-xr-x 1 root root 4001964 3月 31 12:42 opcache.a*
-rwxr-xr-x 1 root root 2016920 3月 31 12:42 opcache.so*
-rwxr-xr-x 1 root root 4638752 3月 31 13:23 swoole.so*
编辑php.ini文件,往文件中插入 extension=swoole 这行。
image.png
测试是否安装swoole成功
season@ubuntu:~/Downloads/swoole/examples/server$ /usr/local/php/bin/php echo.php
另开终端
season@ubuntu:/usr/local/php/lib$ sudo netstat -anp |grep 9501
tcp 0 0 0.0.0.0:9501 0.0.0.0:* LISTEN 106867/php
可以看到用php启的一个106867进程,端口号9501(echo.php文件)
ok
网友评论