首页 php教程 php手册 ubuntu 上给PHP安装扩展 Msgpack 和 Yar

ubuntu 上给PHP安装扩展 Msgpack 和 Yar

Jun 06, 2016 pm 07:59 PM
php ubuntu 安装 扩展

首先说明Yar是干什么的。 新浪著名的大神级人物鸟哥,开发的一个支持并行的PHP扩展。 源地址http://www.laruence.com/2012/09/15/2779.html 其特点就是可以高效的封装好供外部访问的接口,用途嘛, ,你懂的。 下面开始实况直播,如何才能把大神的yar用上。


首先说明Yar是干什么的。


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

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


其特点就是可以高效的封装好供外部访问的接口,用途嘛,ubuntu 上给PHP安装扩展 Msgpack 和  Yar,你懂的。


下面开始实况直播,如何才能把大神的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用户后重新执行上面的命令


ubuntu 上给PHP安装扩展 Msgpack 和  Yar内容太多,截下最后的一段吧。


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

ubuntu 上给PHP安装扩展 Msgpack 和  Yar

ubuntu 上给PHP安装扩展 Msgpack 和  Yar到此为止,我们就安装完了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 <curl-dir>/include/curl/
ERROR: `/tmp/pear/temp/yar/configure' failed
</curl-dir>
登录后复制

在这里我们可以看到是由于我们缺少一个 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中并没有看见对应的扩展。

本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

AI Hentai Generator

AI Hentai Generator

免费生成ai无尽的。

热门文章

R.E.P.O.能量晶体解释及其做什么(黄色晶体)
3 周前 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳图形设置
3 周前 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.如果您听不到任何人,如何修复音频
3 周前 By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25:如何解锁Myrise中的所有内容
4 周前 By 尊渡假赌尊渡假赌尊渡假赌

热工具

记事本++7.3.1

记事本++7.3.1

好用且免费的代码编辑器

SublimeText3汉化版

SublimeText3汉化版

中文版,非常好用

禅工作室 13.0.1

禅工作室 13.0.1

功能强大的PHP集成开发环境

Dreamweaver CS6

Dreamweaver CS6

视觉化网页开发工具

SublimeText3 Mac版

SublimeText3 Mac版

神级代码编辑软件(SublimeText3)

适用于 Ubuntu 和 Debian 的 PHP 8.4 安装和升级指南 适用于 Ubuntu 和 Debian 的 PHP 8.4 安装和升级指南 Dec 24, 2024 pm 04:42 PM

PHP 8.4 带来了多项新功能、安全性改进和性能改进,同时弃用和删除了大量功能。 本指南介绍了如何在 Ubuntu、Debian 或其衍生版本上安装 PHP 8.4 或升级到 PHP 8.4

CakePHP 日期和时间 CakePHP 日期和时间 Sep 10, 2024 pm 05:27 PM

为了在 cakephp4 中处理日期和时间,我们将使用可用的 FrozenTime 类。

讨论 CakePHP 讨论 CakePHP Sep 10, 2024 pm 05:28 PM

CakePHP 是 PHP 的开源框架。它的目的是使应用程序的开发、部署和维护变得更加容易。 CakePHP 基于类似 MVC 的架构,功能强大且易于掌握。模型、视图和控制器 gu

CakePHP 文件上传 CakePHP 文件上传 Sep 10, 2024 pm 05:27 PM

为了进行文件上传,我们将使用表单助手。这是文件上传的示例。

CakePHP 创建验证器 CakePHP 创建验证器 Sep 10, 2024 pm 05:26 PM

可以通过在控制器中添加以下两行来创建验证器。

如何设置 Visual Studio Code (VS Code) 进行 PHP 开发 如何设置 Visual Studio Code (VS Code) 进行 PHP 开发 Dec 20, 2024 am 11:31 AM

Visual Studio Code,也称为 VS Code,是一个免费的源代码编辑器 - 或集成开发环境 (IDE) - 可用于所有主要操作系统。 VS Code 拥有针对多种编程语言的大量扩展,可以轻松编写

CakePHP 快速指南 CakePHP 快速指南 Sep 10, 2024 pm 05:27 PM

CakePHP 是一个开源MVC 框架。它使开发、部署和维护应用程序变得更加容易。 CakePHP 有许多库可以减少大多数常见任务的过载。

您如何在PHP中解析和处理HTML/XML? 您如何在PHP中解析和处理HTML/XML? Feb 07, 2025 am 11:57 AM

本教程演示了如何使用PHP有效地处理XML文档。 XML(可扩展的标记语言)是一种用于人类可读性和机器解析的多功能文本标记语言。它通常用于数据存储

See all articles