ubuntu 上给PHP安装扩展 Msgpack 和 Yar
首先说明Yar是干什么的。 新浪著名的大神级人物鸟哥,开发的一个支持并行的PHP扩展。 源地址http://www.laruence.com/2012/09/15/2779.html 其特点就是可以高效的封装好供外部访问的接口,用途嘛, ,你懂的。 下面开始实况直播,如何才能把大神的yar用上。
首先说明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)
### 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中并没有看见对应的扩展。

핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

Video Face Swap
완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

인기 기사

뜨거운 도구

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

뜨거운 주제











PHP 8.4는 상당한 양의 기능 중단 및 제거를 통해 몇 가지 새로운 기능, 보안 개선 및 성능 개선을 제공합니다. 이 가이드에서는 Ubuntu, Debian 또는 해당 파생 제품에서 PHP 8.4를 설치하거나 PHP 8.4로 업그레이드하는 방법을 설명합니다.

숙련된 PHP 개발자라면 이미 그런 일을 해왔다는 느낌을 받을 것입니다. 귀하는 상당한 수의 애플리케이션을 개발하고, 수백만 줄의 코드를 디버깅하고, 여러 스크립트를 수정하여 작업을 수행했습니다.

VS Code라고도 알려진 Visual Studio Code는 모든 주요 운영 체제에서 사용할 수 있는 무료 소스 코드 편집기 또는 통합 개발 환경(IDE)입니다. 다양한 프로그래밍 언어에 대한 대규모 확장 모음을 통해 VS Code는

JWT는 주로 신분증 인증 및 정보 교환을 위해 당사자간에 정보를 안전하게 전송하는 데 사용되는 JSON을 기반으로 한 개방형 표준입니다. 1. JWT는 헤더, 페이로드 및 서명의 세 부분으로 구성됩니다. 2. JWT의 작업 원칙에는 세 가지 단계가 포함됩니다. JWT 생성, JWT 확인 및 Parsing Payload. 3. PHP에서 인증에 JWT를 사용하면 JWT를 생성하고 확인할 수 있으며 사용자 역할 및 권한 정보가 고급 사용에 포함될 수 있습니다. 4. 일반적인 오류에는 서명 검증 실패, 토큰 만료 및 대형 페이로드가 포함됩니다. 디버깅 기술에는 디버깅 도구 및 로깅 사용이 포함됩니다. 5. 성능 최적화 및 모범 사례에는 적절한 시그니처 알고리즘 사용, 타당성 기간 설정 합리적,

이 튜토리얼은 PHP를 사용하여 XML 문서를 효율적으로 처리하는 방법을 보여줍니다. XML (Extensible Markup Language)은 인간의 가독성과 기계 구문 분석을 위해 설계된 다목적 텍스트 기반 마크 업 언어입니다. 일반적으로 데이터 저장 AN에 사용됩니다

문자열은 문자, 숫자 및 기호를 포함하여 일련의 문자입니다. 이 튜토리얼은 다른 방법을 사용하여 PHP의 주어진 문자열의 모음 수를 계산하는 방법을 배웁니다. 영어의 모음은 A, E, I, O, U이며 대문자 또는 소문자 일 수 있습니다. 모음이란 무엇입니까? 모음은 특정 발음을 나타내는 알파벳 문자입니다. 대문자와 소문자를 포함하여 영어에는 5 개의 모음이 있습니다. a, e, i, o, u 예 1 입력 : String = "Tutorialspoint" 출력 : 6 설명하다 문자열의 "Tutorialspoint"의 모음은 u, o, i, a, o, i입니다. 총 6 개의 위안이 있습니다

정적 바인딩 (정적 : :)는 PHP에서 늦은 정적 바인딩 (LSB)을 구현하여 클래스를 정의하는 대신 정적 컨텍스트에서 호출 클래스를 참조 할 수 있습니다. 1) 구문 분석 프로세스는 런타임에 수행됩니다. 2) 상속 관계에서 통화 클래스를 찾아보십시오. 3) 성능 오버 헤드를 가져올 수 있습니다.

PHP의 마법 방법은 무엇입니까? PHP의 마법 방법은 다음과 같습니다. 1. \ _ \ _ Construct, 객체를 초기화하는 데 사용됩니다. 2. \ _ \ _ 파괴, 자원을 정리하는 데 사용됩니다. 3. \ _ \ _ 호출, 존재하지 않는 메소드 호출을 처리하십시오. 4. \ _ \ _ get, 동적 속성 액세스를 구현하십시오. 5. \ _ \ _ Set, 동적 속성 설정을 구현하십시오. 이러한 방법은 특정 상황에서 자동으로 호출되어 코드 유연성과 효율성을 향상시킵니다.
