PHP 7下安裝Swoole和Yar、Yaf

安裝步驟php

1.wget -c https://github.com/swoole/swoole-src/archive/v2.0.8.tar.gz  百度盤連接:https://pan.baidu.com/s/1xqrIBq_xerG7tCMgttKnNw 密碼:j4hs
html

2.tar -zxvf v2.0.8.tar.gz//解壓縮 而後cd進入壓縮後目錄nginx

3.這個時候須要使用phpize生成編譯文件(在這裏附上http://www.cnblogs.com/hubing/p/4941692.html對phpize的解釋 已經很明瞭了){git

phpize的做用能夠這樣理解:偵測環境(phpize工具是在php安裝目錄下,基於這點phpize對應了當時的php環境,因此是要根據該php的配置狀況生成對應的configure文件),創建一個configure文件。必須在一個目錄下去運行phpize。那麼phpize就知道你的的環境是哪一個目錄,而且configure文件創建在該目錄下。github

}json

此時的我保錯以下:Can't find PHP headers in /usr/include/php The php-devel package is required for use of this command.swoole

解決方法:yum install php70w-develmarkdown

4.執行phpize  /usr/bin/phpize(記得要在swoole擴展目錄下執行)php7

5.執行 ./configureapp

6.而後就是 make && make install 一塊兒走完

7.最後要修改下php.ini  添加extension=swoole.so

8.記得重啓服務

 

OK ! 此時執行php -m 能夠看到多了個swoole就說明成功了

筆者開發壞境:CentOS7,PHP 7.0.16

安裝PECL

//php版本 > 7 $ wget http://pear.php.net/go-pear.phar $ php go-pear.phar //php版本 < 7 $ yum install php-pear //不然會報錯PHP Parse error: syntax error, unexpected //'new' (T_NEW) in /usr/share/pear/PEAR/Frontend.php on //line 91
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

安裝swoole

$ sudo pecl  install swoole

//報錯以下 //Warning: Invalid argument supplied for foreach() in //Command.php on line 249 vi `which pecl` //找到最後一行 exec $PHP -C -n -q $INCARG -d date.timezone=UTC -d output_buffering=1 -d variables_order=EGPCS -d safe_mode=0 -d register_argc_argv="On" $INCDIR/peclcmd.php "$@" 去掉 -n 標示 //報錯以下 //running: phpize //Can't find PHP headers in /usr/include/php 安裝 PHP devel 成功! //Build process completed successfully //Installing '/usr/lib64/php/modules/swoole.so' //install ok: channel://pecl.php.net/swoole-1.9.8 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23

配置 php.ini

$ php -i | grep php.ini //修改或者添加 extension=swoole.so
  • 1
  • 2
  • 3

安裝 yar

$ sudo ./pecl install msgpack //pecl/yar requires PHP (version >= 5.2.0, version <= 5.6.99), installed version is 7.0.16 //注意PHP7,要使用yar-2.0.2 $ sudo ./pecl install yar-2.0.2 //注意yar-2.0.2版本 //添加,json.so 要放到前面。不然會報 //PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/yar.so' - /usr/lib64/php/modules/yar.so: undefined symbol: php_json_decode_ex in Unknown on line 0 extension=json.so //放前面 extension=swoole.so extension=msgpack.so extension=yar.so 其餘問題!!! //報錯 //perl: warning: Setting locale failed. //perl: warning: Please check that your locale //settings: // LANGUAGE = (unset), // LC_ALL = (unset), // LANG = "en_US.UTF-8" $ localedef -v -c -i en_US -f UTF-8 en_US.UTF-8 //報錯 //checking for cURL in default path... not found //configure: error: Please reinstall the libcurl distribution - easy.h should be in <curl-dir>/include/curl/ $ sudo yum -y install curl-devel 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30

安裝Yaf

$ sudo ./pecl install yaf //更新php.ini extension=yaf.so //重啓服務 $ sudo systemctl restart php-fpm.service //安裝腳手架 $ git clone http://pecl.php.net/package/yaf $ cd php-yaf/tools/cg $ php yaf-cg app //配置 項目目錄指向 app/index.php //訪問配置host
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

nginx配置

server {
  listen ****; server_name domain.com; root document_root; index index.php index.html index.htm; if (!-e $request_filename) { rewrite ^/(.*) /index.php/$1 last; } } 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

Enjoy it!

yar

swoole

msgpack

這裏寫圖片描述

相關文章
相關標籤/搜索