多应用+插件架构,代码干净,支持一键云编译,码云点赞13K star,4.8-4.12 预售价格198元 广告
这篇笔记是在php7刚出来不久,然后当时测试性能的时候源码安装swoole的时候记录的,当时是记录在word里,虽然现在都使用docker了,还是在这里分享出来吧。 # swoole 源代码 编译安装 ## 源码安装git 其实这种工具类的软件直接`yum install `好了,但是我这里也源码安装了。 ### 步骤1. 安装依赖包 `yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel` ` yum install gcc perl-ExtUtils-MakeMaker` ### 步骤2. 卸载旧的git版本(如果之前有安装rpm包) yum remove git ### 步骤3. 下载&解压 ``` cd /usr/src wget https://www.kernel.org/pub/software/scm/git/git 2.5.0.tar.gz tar -zxvf git-2.5.0.tar.gz ``` 或 ` wget https://github.com/git/git/archive/v2.5.0.tar.gz` 下载 步骤4. 编译安装 ``` cd git-2.5.0 make prefix=/usr/local/bin/git all make prefix=/usr/local/git install echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc source /etc/bashrc ``` ## 安装 openssl ``` wget http://www.openssl.org/source/openssl-1.0.2j.tar.gz tar -zxvf ./config --prefix=/usr/local/openssl make install ``` cp openssl 到 sbin 下 ## 源码安装swoole ### 下载swoole源码 git clone https://gitee.com/swoole/swoole.git ![](https://img.kancloud.cn/a2/c2/a2c2a84e0ce9919bb98f7acd085915fc_642x219.png) ### phpize 生成 swoole 安装config文件 ![](https://img.kancloud.cn/26/1e/261ea19f69bd044020b6095057a62f4e_649x80.png) 找到 phpize 目录并来到swoole 的目录: ![](https://img.kancloud.cn/52/de/52deb4026613aa5c830df20cad5a5bc6_638x151.png) 说我缺少 autoconf 我安装一下 `yum install autoconf` phpize 再试一次 没报错 ![](https://img.kancloud.cn/04/2b/042bbe60698af13354148e79a11728ed_639x95.png) `./configure --enable-openssl --with-php-config=/usr/php-7.2.5/bin/php-config` 各种报错 看看缺啥就按啥即可。 ### 编译安装swoole ![](https://img.kancloud.cn/47/b8/47b80f4a60fd6827d30370acdef06870_644x163.png) cd /usr/php-7.2.5/lib/php/extensions/no-debug-non-zts-20170718/ 下看看 ![](https://img.kancloud.cn/f0/75/f075ff8c2d6c39bfb72ea48dc51c2cba_643x66.png) 多了三个文件 回到之前目录 ![](https://img.kancloud.cn/32/28/32286237487a26962466efb10c03a932_641x53.png) 找到 /home/soft/swoole/examples/server/echo.php php echo.php 执行以下 报错 ![](https://img.kancloud.cn/84/62/84626c712b12763e1de25b9cfa596ec4_639x223.png) 找不到这个类?? 修改 ini文件 增加扩展 `vi /usr/php-7.2.5/lib/php.ini ``` 加上 swoole 扩展 保存 php -m 看一眼 ![](https://img.kancloud.cn/b8/e2/b8e22c12b075389b44e7f8f9f6b96542_644x385.png) php 执行以下 之前的文件 /home/soft/swoole/examples/server/echo.php 没反应 打开另一个终端 `netstat -anp | grep 9501` ![](https://img.kancloud.cn/d7/ff/d7ff959a5eed86ed4ff1b55073520c05_643x110.png) 成功 >附一个php编译命令 `./configure --prefix=/usr/local/php \--prefix=/usr/local/php \--with-config-file-path=/usr/local/php/etc \-with-libxml-dir=/usr \--with-iconv-dir \--with-mhash \--with-openssl \--with-mysqli=shared,mysqlnd \--with-pdo-mysql=shared,mysqlnd \--with-zlib \--enable-zip \--enable-inline-optimization \--disable-debug \--disable-rpath \--enable-shared \--enable-xml \--enable-bcmath \--enable-shmop \--enable-sysvsem \--enable-mbregex \--enable-pcntl \--enable-sockets \--without-pear \--with-gettext \--enable-session`