本文为原创作品,转载请注明出处!

首先说明Yar是干什么的。

新浪著名的大神级人物鸟哥,开发的一个支持并行的PHP扩展。

源地址 http://www.laruence.com/2012/09/15/2779.html

其特点就是可以高效的封装好供外部访问的接口,用途嘛,

,你懂的。

下面开始实况直播,如何才能把大神的yar用上。

一、下载。

恩,没错,在那个文章的底部,鸟哥提供了github的下载地址。

但是,这是不够的,因为这个框架需要 一个名为 Msgpack的扩展,同样的,这个也是鸟哥维护的,再次膜拜!!

二、msgpack。

恩。。。。。

貌似下载好发现里面都是写.c .h 的文件,没错,我们需要自己来编译!

1.msgpack

解压压缩包,直接看 README.md

## Install

### Install from PECL

Msgpack is an PECL extension, thus you can simply install it by:

````

pecl install msgpack

````

### Compile Msgpack from source

````

$/path/to/phpize

$./configure

$make && make install

````

恩,我们发现原来这个可以通过pecl在线安装

打开一个终端,输入

pecl install msgpack

发现没有成功,给的提示是这样的

Failed to download pecl/msgpack within preferred state "stable", latest release is version 0.5.5, stability "beta", use "channel://pecl.php.net/msgpack-0.5.5" to install

install failed

这是由于msgpack还没有稳定版本,按照上面的提示,我们这样输入

pecl install  channel://pecl.php.net/msgpack-0.5.5

还是没有成功,但是提示变了

WARNING: configuration download directory "/build/buildd/php5-5.5.3+dfsg/pear-build-download" is not writeable.  Change download_dir config variable to a writeable dir to avoid this warning

Cannot install, php_dir for channel "pecl.php.net" is not writeable by the current user

看来是我们对文件夹没有写入权限,下面我们切换到root用户后重新执行上面的命令

内容太多,截下最后的一段吧。

Build process completed successfully

Installing '/usr/lib/php5/20121212/msgpack.so'

Installing '/usr/include/php5/ext/msgpack/php_msgpack.h'

install ok: channel://pecl.php.net/msgpack-0.5.5

configuration option "php_ini" is not set to php.ini location

You should add "extension=msgpack.so" to php.ini

下面的操作就是打开配置文件,把扩展写到文件中去

sudo gedit /etc/php5/apache2/php.ini

然后重启apache

sudo /etc/init.d/apache2 restart

查看phpinfo

到此为止,我们就安装完了msgpack的PHP扩展。

三、Yar

解压下载的 yar-master.zip 我们还是先看 README.md 这个文件,其实直接在github上看也是一样的。。。。

安装要求,要求安装一下的php扩展,这就是上一步的重要性!

## Requirement

- PHP 5.2+

- Curl

- Json

- Msgpack (Optional)

安装yar

### Install Yar

Yar is an PECL extension, thus you can simply install it by:

```

pecl install yar

```

看来我们也可以通过pecl命令直接进行安装啊,貌似不是那么顺利

downloading yar-1.2.1.tgz ...

Starting to download yar-1.2.1.tgz (35,174 bytes)

.........done: 35,174 bytes

28 source files, building

running: phpize

Configuring for:

PHP Api Version:         20121113

Zend Module Api No:      20121212

Zend Extension Api No:   220121212

building in /tmp/pear/temp/pear-build-rootoSsn5u/yar-1.2.1

running: /tmp/pear/temp/yar/configure

checking for grep that handles long lines and -e... /bin/grep

checking for egrep... /bin/grep -E

checking for a sed that does not truncate output... /bin/sed

checking for cc... cc

checking whether the C compiler works... yes

checking for C compiler default output file name... a.out

checking for suffix of executables...

checking whether we are cross compiling... no

checking for suffix of object files... o

checking whether we are using the GNU C compiler... yes

checking whether cc accepts -g... yes

checking for cc option to accept ISO C89... none needed

checking how to run the C preprocessor... cc -E

checking for icc... no

checking for suncc... no

checking whether cc understands -c and -o together... yes

checking for system library directory... lib

checking if compiler supports -R... no

checking if compiler supports -Wl,-rpath,... yes

checking build system type... x86_64-unknown-linux-gnu

checking host system type... x86_64-unknown-linux-gnu

checking target system type... x86_64-unknown-linux-gnu

checking for PHP prefix... /usr

checking for PHP includes... -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib

checking for PHP extension directory... /usr/lib/php5/20121212

checking for PHP installed headers prefix... /usr/include/php5

checking if debug is enabled... no

checking if zts is enabled... no

checking for re2c... no

configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.

checking for gawk... no

checking for nawk... nawk

checking if nawk is broken... no

checking whether to enable yar support... yes, shared

checking for curl protocol support... yes, shared

checking for msgpack packager support... no

checking for cURL in default path... not found

configure: error: Please reinstall the libcurl distribution - easy.h should be in /include/curl/

ERROR: `/tmp/pear/temp/yar/configure' failed

在这里我们可以看到是由于我们缺少一个 re2c 0.13.4 或者更新的版本才行,还有,我们的curl模块也不太符合要求,要求重装一下。

下面开始解决问题!

我在这个地址里找到了 re2c http://download.csdn.net/download/morre/5702707 ,在下面的解决过程中跳过了re2c的安装,看来上面的只是警告,没有太大问题。

让我们回到yar的编译

编译需要 phpize,所以我们要安装 phpize,安装phpize需要运行

yum install php-devel

返回的提示是

程序“yum”尚未安装。 您可以使用以下命令安装:

sudo apt-get install yum

恩,所以先安装yum,在安装phpize,注意,安装phpize的时候要以root用户执行!

然后重新安装了curl库,重启apache

sudo apt-get install curl libcurl3 libcurl3-dev php5-curl

sudo /etc/init.d/apache2 restart

下面再次执行pecl的安装

pecl install yar

然后就没有问题啦,经过短暂的等待,显示下面的提示,就安装完成啦!

Build process completed successfully

Installing '/usr/lib/php5/20121212/yar.so'install ok:

channel://pecl.php.net/yar-1.2.1configuration option "php_ini" is not set to php.ini locationYou should add "extension=yar.so" to php.ini

下面的步骤和上次一样,修改配置文件,重启apache。

sudo gedit /etc/php5/apache2/php.ini

sudo /etc/init.d/apache2 restart

重启之后,在phpinfo中并没有看见对应的扩展。

php msgpack 扩展,ubuntu 上给PHP安装扩展 Msgpack 和 Yar相关推荐

  1. 在Ubuntu上源码安装MySQL+安装问题解决+安全优化

    当然,MySQL的安装方法多种多样,在Ubuntu上,你可以采用apt-get的方式安装,这样的好处是:快速方便.基本上,它会帮你解决所有的函数库依赖问题,正常情况下,只要apt-get执行完成,那么 ...

  2. Ubuntu上nfs的安装配置

    Ubuntu上nfs的安装配置 2007-07-01 09:04 Ubuntu 默认是没有nfs服务的,所以需要自己安装 1.安装nfs服务版            apt-get install n ...

  3. Windows学习总结(23)——在 Windows 10 子系统 ubuntu 上利用 WSL2 安装 docker 的 2 种方式

    前言 windows10 目前推出了WSL2,相对于WSL采用API转换的方式, WSL2 则完全不同,win10 开始内置了一个轻量级虚拟机,经过不断的优化,这个虚拟机实现了与 windows 的高 ...

  4. PyTorch——Ubuntu上Pytorch的安装教程

    1 致谢 感谢网友夜幕下的光123提供的帮助, 原文链接如下: https://blog.csdn.net/songchunxiao1991/article/details/95192063 2 前言 ...

  5. Ubuntu上mysql的安装及使用【转】

    原创 Ubuntu上mysql的安装及使用 2019-02-10 13:54:24 baiduoWang 阅读数 196更多 分类专栏: Linux MySql 版权声明:本文为博主原创文章,遵循 C ...

  6. 在Ubuntu上用python3安装caffe(仅CPU)

    在Ubuntu上用python3安装caffe(仅CPU) 现在网上安装caffe的版本基本上都是基于python 2.7的,本教程旨在用anaconda 3安装caffe cpu,其过程非常艰辛,连 ...

  7. debian编译php mysql5.6_在Debian/Ubuntu上免编译安装PHP7.2~5.6

    本文介绍在 Debian/Ubuntu 系统上免编译安装 PHP7.2~5.6,教程适用系统为:Debian 9.Deiban 8.Ubuntu 18.04 LTS.Ubuntu 16.04 LTS. ...

  8. linux wireshark使用教程,技术|Ubuntu 上 Wireshark 的安装与使用

    在本教程中,你将学习如何在 Ubuntu 和其它基于 Ubuntu 的发行版上安装最新的 Wireshark.同时你也将学习如何在没有 sudo 的情况下来运行 Wireshark,以及如何设置它来进 ...

  9. Ubuntu上通过 RVM 安装 多版本 Ruby/Rails

    2019独角兽企业重金招聘Python工程师标准>>> Rails 3 RC 版半个月前就已经发布,而正式版据说会在未来几周内面世.相对于 2.3 版,Rails 3 差不多在各个方 ...

最新文章

  1. OMG!Semaphore里面居然有这么一个大坑!
  2. win10下mysql 8.0.18 安装配置方法图文教程
  3. iframe学习总结
  4. 从头搭建 IntelliJ IDEA 环境,从放弃到爱不释手!
  5. git 删除远程分支和本地分支
  6. 别用symbolicatecrash来解析crash Log了
  7. 谷歌云服务器支持udp,谷歌浏览器扩展使用UDP
  8. 手把手教你使用si9000计算高速差分线的阻抗
  9. RecycleView获取所有的ViewHolder
  10. logistic映射图像加密matlab,基于Logistic映射与排序变换的图像加密算法
  11. dht11 java_树莓派使用DHT11温湿度传感器
  12. 华为手机默认浏览器打开应用宝链接直接启动应用问题解决
  13. 导出数据提示--secure-file-priv选项问题的解决方法
  14. 禅与摩托车维修艺术中提到的“刀”
  15. java给文件777权限_Linux常用命令:chmod修改文件权限 777和755分别是什么意思?
  16. 【图解数据结构与算法】视频教程正式上线B站,持续更新中......
  17. opencv RGB与HSV转化
  18. 盟百照相馆影楼摄影工作室选片系统
  19. 事务统计系统软件 php,PHP数据库事务处理
  20. 破解QQ2008会员涂鸦QQ表情

热门文章

  1. Linux图形管理框架gdm3、lightdm、sddm、kdm介绍(一百三十七)
  2. 一个浏览器只运行登录一个用户
  3. 怎么看陌陌新推出的陌陌现场呢?
  4. 银联8583报文域小结
  5. A40I 修改fex配置
  6. 线性表的顺序存储结构及操作的实现
  7. CDH6.3.1部署
  8. JS基础:JavaScript 起源以及介绍
  9. 联想一直提示正在更新计算机启动配置,电脑一直显示准备配置windows的问题
  10. HTML网页设计语言入门基础教学视频-赖国荣-专题视频课程