分享在PHP 7下安裝Swoole與Yar,Yaf的方法教程

來源:互聯網
上載者:User
周末閑來無事,玩玩swoole,所以下面這篇文章主要給大家介紹了在PHP 7下安裝Swoole與Yar,Yaf的方法教程,文中介紹的非常詳細,對大傢具有一定的參考學習價值,需要的朋友們下面來一起看看吧。

本文開發壞境:

  • CentOS 7

  • 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

安裝swoole

$ sudo pecl install swoole//報錯如下//Warning: Invalid argument supplied for foreach() in //Command.php on line 249vi `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-develsudo yum install php70w-devel成功!//Build process completed successfully//Installing '/usr/lib64/php/modules/swoole.so'//install ok: channel://pecl.php.net/swoole-1.9.8

配置 php.ini

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

安裝 Yar和Yaf

$ 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 0extension=json.so //放前面extension=msgpack.soextension=yar.so//重啟php服務sudo systemctl restart php-fpm.service//其他報錯//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//安裝Yaf$ sudo ./pecl install yaf//更新php.iniextension=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

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; }}

Enjoy it!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.