ubuntu 上给PHP安装扩展 Msgpack 和 Yar

简介: 本文为原创作品,转载请注明出处! 首先说明Yar是干什么的。 新浪著名的大神级人物鸟哥,开发的一个支持并行的PHP扩展。 源地址 http://www.laruence.com/2012/09/15/2779.html 其特点就是可以高效的封装好供外部访问的接口,用途嘛,,你懂的。

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


首先说明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 <curl-dir>/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中并没有看见对应的扩展。

目录
相关文章
|
6天前
|
监控 Linux PHP
【02】客户端服务端C语言-go语言-web端PHP语言整合内容发布-优雅草网络设备监控系统-2月12日优雅草简化Centos stream8安装zabbix7教程-本搭建教程非docker搭建教程-优雅草solution
【02】客户端服务端C语言-go语言-web端PHP语言整合内容发布-优雅草网络设备监控系统-2月12日优雅草简化Centos stream8安装zabbix7教程-本搭建教程非docker搭建教程-优雅草solution
54 20
|
6天前
|
Ubuntu API 网络虚拟化
ubuntu22 编译安装docker,和docker容器方式安装 deepseek
本脚本适用于Ubuntu 22.04,主要功能包括编译安装Docker和安装DeepSeek模型。首先通过Apt源配置安装Docker,确保网络稳定(建议使用VPN)。接着下载并配置Docker二进制文件,创建Docker用户组并设置守护进程。随后拉取Debian 12镜像,安装系统必备工具,配置Ollama模型管理器,并最终部署和运行DeepSeek模型,提供API接口进行交互测试。
130 15
|
27天前
|
运维 JavaScript 应用服务中间件
os-copilot安装与多项功能测评,帮助开发人员PHP环境排查问题
本文介绍了OS Copilot在ECS上 Alibaba Cloud Linux的安装与使用,并对其多项参数进行了功能测评。OS Copilot是为操作系统提供智能化辅助的工具,支持自动化任务、智能推荐、故障排查等功能。安装时需检查是否已安装(`rpm -q os-copilot`),若未安装则用`yum install os-copilot`命令安装,并配置AccessKey信息连接阿里云服务。通过测试不同参数命令,如`-t`参数,展示了其自动化执行和智能生成回答的能力,显著提升运维效率。
os-copilot安装与多项功能测评,帮助开发人员PHP环境排查问题
|
27天前
|
弹性计算 Ubuntu Java
OS-Copilot-ubuntu镜像版本的具体测试使用(安装方式有单独注明)
作为一名个人开发者,我主要负责云资源的运维和管理。在使用OS Copilot的过程中,我遇到了一些配置问题,特别是在ECS实例中设置AccessKey时,但最终成功解决了。通过使用OS Copilot的-t/-f/管道功能,我大大提升了效率,减少了命令编写的工作量,特别是在搭建Java运行环境时效果显著。此外,| 功能帮助我快速理解文档,整体体验非常流畅,推荐给其他开发者使用。
39 6
|
2月前
|
开发框架 小程序 前端开发
圈子社交app前端+后端源码,uniapp社交兴趣圈子开发,框架php圈子小程序安装搭建
本文介绍了圈子社交APP的源码获取、分析与定制,PHP实现的圈子框架设计及代码编写,以及圈子小程序的安装搭建。涵盖环境配置、数据库设计、前后端开发与接口对接等内容,确保平台的安全性、性能和功能完整性。通过详细指导,帮助开发者快速搭建稳定可靠的圈子社交平台。
|
2月前
|
监控 关系型数据库 MySQL
Ubuntu24.04安装Librenms
此指南介绍了在Linux系统上安装和配置LibreNMS网络监控系统的步骤。主要内容包括:安装所需软件包、创建用户、克隆LibreNMS仓库、设置文件权限、安装PHP依赖、配置时区、设置MariaDB数据库、调整PHP-FPM与Nginx配置、配置SNMP及防火墙、启用命令补全、设置Cron任务和日志配置,最后通过网页完成安装。整个过程确保LibreNMS能稳定运行并提供有效的网络监控功能。
|
2月前
|
JSON Ubuntu 开发者
ubuntu 22安装lua环境&&编译lua cjson模块
通过上述步骤,可以在 Ubuntu 22.04 系统上成功安装 Lua 环境,并使用 LuaRocks 或手动编译的方式安装 lua-cjson 模块。本文详细介绍了每一步的命令和操作,确保每一步都能顺利完成,适合需要在 Ubuntu 系统上配置 Lua 开发环境的开发者参考和使用。
190 13
|
2月前
|
Ubuntu Linux Docker
Ubuntu22.04上Docker的安装
通过以上详细的安装步骤和命令,您可以在Ubuntu 22.04系统上顺利安装
1302 12
|
3月前
|
Ubuntu
ubuntu和debian 的安装包dpkg管理命令对安装包进行安装,查询,卸载
Ubuntu dpkg 软件包管理命令概览:安装、卸载、查看和配置软件包。包括解决依赖、强制卸载、列出及过滤已安装包、查看包详情等操作。
130 10
|
3月前
|
Ubuntu API 开发工具
PSOPT在Ubuntu22.04下的安装
通过上述步骤,可以在Ubuntu 22.04下成功安装并配置PSOPT。PSOPT是一个功能强大的工具,适用于解决各种最优控制问题。确保在安装前满足系统要求,并仔细按照步骤操作,可以避免大多数常见问题。通过MATLAB与PSOPT的结合,您可以更高效地处理复杂的控制问题,并获得准确的解决方案。
51 5

热门文章

最新文章