1.0安裝前的準備
升級PHP系統爲7.0以上版本,gcc 4.8以及以上版本,make,autoconf,pcre(CentOS
系統可以執行命令:yum install pcre-devel
)
1.1安裝git:yum –y install git
1.2克隆swoole源碼:git clone …
地址:
https://github.com/swoole/swoole-src/releases
http://pecl.php.net/package/swoole
http://git.oschina.net/swoole/swoole
1.3執行編譯
cd swoole
phpize (ubuntu 沒有安裝phpize可執行命令:sudo apt-get install php-dev來安裝phpize)
./configure
make
sudo make install
1.4進階篇編譯
初次接觸swoole的開發者請先嚐試上方的簡單編譯,如果有進一步的需要,可以根據具體的需求和版本,調整以下示例的編譯參數
mkdir -p ~/build && \
cd ~/build && \
rm -rf ./swoole-src && \
curl -o ./tmp/swoole.tar.gz https://github.com/swoole/swoole-src/archive/master.tar.gz -L && \
tar zxvf ./tmp/swoole.tar.gz && \
mv swoole-src* swoole-src && \
cd swoole-src && \
phpize && \
./configure \
--enable-coroutine \
--enable-openssl \
--enable-http2 \
--enable-async-redis \
--enable-sockets \
--enable-mysqlnd && \
make clean && make && sudo make install
1.5安裝pecl:yum install php-devel php-pear
執行一鍵安裝:pecl install swoole
1.6配置php.ini
查找php.ini文件:find / -name "php.ini"
編譯安裝成功後:extension=swoole.so
1.7查看是否成功:php –m