乐美客SBC专区
直播中

gnensis

13年用户 128经验值
擅长:嵌入式技术 控制/MCU
私信 关注
[香蕉派申请]

【HiKey试用体验】05. 在HiKey上安装swoole开发环境

    上一篇在HiKey上安装好了PHP运行环境,这一贴来记录怎样在HiKey上装swoole开发环境。
swoole算是一个比较新的东东,下面简单说下swoole(http://www.swoole.com)是啥东东:
    swoole是一种PHP高级Web开发框架。swoole的目标是向Java框架、Ruby On Rails、Python Django Pylons等一流框架发起挑战。swoole以php扩展模块的方式运行,其用C语言开发而成,更接近操作系统底层,所以比用PHP语言实现的框架效率更高。
    swoole有如下的特色:
    特色1:用C语言实现、高性能;
    特色2:简单易用;
    特色3:事件驱动、无阻塞;
    特色4:支持C1000K;
    特色5:支持TCP、UDP和Unix域套接字;
    特色6:支持服务端和客户端开发;
    特色7:半同步、半异步工作模式;
    特色8:支持SSL、TLS加密;
    特色9:支持IPv4和IPv6;


    swoole在HiKey上的安装:
一、下载源码
    1.1 下载地址为:https://github.com/swoole/swoole-src/archive/swoole-1.8.5-stable.tar.gz
    1.2 下载方法: wget https://github.com/swoole/swoole-src/archive/swoole-1.8.5-stable.tar.gz
二、编译安装
     2.0 准备工作:apt-get install cmake
     2.1 解压:tar xzvf swoole-1.8.5-stable.tar.gz
     2.2 编译:
     cd swoole-1.8.5-stable
     phpize
     ./configure
      make

Libraries have been installed in:
   /home/walker/software/swoole-src-swoole-1.8.5-stable/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

Build complete.
Don't forget to run 'make test'.

     2.3 安装:sudo make install
     2.4 配置:
     先找到php的配置文件
walker@HiKey:~/software/swoole-src-swoole-1.8.5-stable$ sudo find / -name php.ini
/etc/php5/apache2/php.ini
/etc/php5/cli/php.ini

     由于我们不实用apache2,所以这了起作用的配置文件是:/etc/php5/cli/php.ini
      在php.ini中加入如下一句配置:
      extension=swoole.so


三、测试验证
3.1 使用phpinfo函数验证
3.1.1 创建一个名为phpinfo.php的文件,并在其中写入以下内容
phpinfo();
?>
3.1.2 验证:php phpinfo.php | grep swoole
walker@HiKey:~/_test/phpinfo$ php phpinfo.php | grep swoole
swoole
swoole support => enabled
swoole.aio_thread_num => 2 => 2
swoole.display_errors => On => On
swoole.message_queue_key => 0 => 0
swoole.unixsock_buffer_size => 8388608 => 8388608
swoole.use_namespace => Off => Off
walker@HiKey:~/_test/phpinfo$

出现以上内容则说明swoole配置成功。
3.2 使用swoole源码中的example验证:
3.2.1 安装telnet:sudo apt-get install telnet
3.2.2 运行echo例子:
      cd swoole-src-swoole-1.8.5-stable/examples/server
       php echo.php


       在另一个窗口运行:
       walker@HiKey:~$ telnet localhost 9501
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
lllll
hello
sssssssss
hello
Connection closed by foreign host.


更多回帖

×
20
完善资料,
赚取积分