search
HomeBackend DevelopmentPHP TutorialHow to quickly and automatically install php extension modules

  1. wget http://pear.php.net/go-pear

  2. php go_pear
  3. [root@localhost ~]# php go-pear

  4. Welcome to go-pear!
  5. Go-pear will install the 'pear' command and all the files needed by

  6. it. This command is your tool for PEAR installation and maintenance.
  7. Go-pear also lets you download and install the following optional PEAR

  8. packages: PEAR_Frontend_Web-beta, PEAR_Frontend_Gtk2, MDB2.
  9. If you wish to abort, press Control-C now, or press Enter to continue:

  10. HTTP proxy (http://user:password@proxy.myhost.com:port), or Enter for none::

  11. Below is a suggested file layout for your new PEAR installation. To

  12. change individual locations, type the number in front of the
  13. directory. Type 'all' to change all of them or simply press Enter to
  14. accept these locations.
  15. 1. Installation prefix ($prefix) : /root

  16. 2. Temporary files directory : $prefix/temp
  17. 3. Binaries directory : $prefix/bin
  18. 4. PHP code directory ($php_dir) : $prefix/PEAR
  19. 5. Documentation base directory : $php_dir/docs
  20. 6. Data base directory : $php_dir/data
  21. 7. Tests base directory : $php_dir/tests
  22. 1-7, 'all' or Enter to continue:

复制代码

可以选择:1 设置你安装路径。 接下来,一路回车就可以完成安装了。 现在,你可以直接运行:pecl pear 2个命令进行安装。

什么是:pear pecl 呢? Pear、Pecl都是PHP扩展模块的集合。 扩展PHP有两种方法: 一种是用纯粹的php代码写函数和类。   Pear就是这样一个项目。PEAR是PHP的官方开源类库(PHP Extension and Application Repository的缩写)。 Pear在英文中是梨子的意思。PEAR将PHP程序开发过程中常用的功能编写成类库,涵盖了页面呈面、数据库访问、文件操作、 数据结构、缓存操作、网络协议等许多方面,用户可以很方便地使用。它是一个PHP扩展及应用的一个代码仓库, 简单地说,PEAR就是PHP的 cpan。其主页是pear.php.net。   另外一种是用c或者c++编写外部模块加载至php中。   Pecl(The PHP Extension Community Library)就是干这个事的,PHP的标准扩展,可以补充实际开发中所需的功能。 所有的扩展都需要安装,在Windows下面以DLL的形式出现;在 linux下面需要单独进行编译, 它的表现形式为根据PHP官方的标准用C语言写成,尽管源码开放但是一般人无法随意更改源码。 其主页是 pecl.php.net。  最直接的表述:Pear是PHP的上层扩展,Pecl是PHP的底层扩展。   这两种方法其实都是为特定的应用提供现成的函数或者类,本质上来说都是一样的。

知道上面 2个区别,对于我们安装很方便理解了。我们一般so文件扩展,需要运行:pecl

2.下面,安装个:pecl_http扩展试下

  1. [root@localhost ~]# pecl search http
  2. Retrieving data...0%
  3. Matched packages, channel pecl.php.net:
  4. =======================================
  5. Package Stable/(Latest) Local
  6. pecl_http 1.7.0 (stable) Extended HTTP Support
  7. You have new mail in /var/spool/mail/root
  8. [root@localhost ~]# pecl install pecl_http
  9. downloading pecl_http-1.7.0.tgz ...
  10. Starting to download pecl_http-1.7.0.tgz (173,979 bytes)
  11. .....................................done: 173,979 bytes
  12. 71 source files, building
  13. running: phpize
  14. Configuring for:
  15. PHP Api Version: 20041225
  16. Zend Module Api No: 20060613
  17. Zend Extension Api No: 220060519
  18. whether to enable cURL HTTP requests; specify libcurl directory [yes] :
复制代码

先运行:search 命令模糊搜索,然后可以用,pecl install pecl_http . 一路回车,一会儿 在: [root@localhost ~]# ll /usr/lib/php/modules/http.so -rw-r--r-- 1 root root 1274476 06-26 08:56 /usr/lib/php/modules/http.so 存在自己的模块了。(不同系统,位置可能不同),上一步安装完后,会告诉模块所在地址。

3.配制php.ini 加入: extension=http.so 就ok了。

然后,可以通过php -m 查看下。

  1. [root@localhost ~]# php -m
  2. [PHP Modules]
  3. bz2
  4. calendar
  5. ctype
  6. curl
  7. date
  8. dbase
  9. dom
  10. eAccelerator
  11. exif
  12. filter
  13. ftp
  14. gd
  15. gettext
  16. gmp
  17. hash
  18. http
Copy code

has been installed successfully. postscript: Others also have source code installation. Go to pecl.php.net to find the corresponding source code package and decompress it. You can pass: pecl install source code file.



Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
What is the full form of PHP?What is the full form of PHP?Apr 28, 2025 pm 04:58 PM

The article discusses PHP, detailing its full form, main uses in web development, comparison with Python and Java, and its ease of learning for beginners.

How does PHP handle form data?How does PHP handle form data?Apr 28, 2025 pm 04:57 PM

PHP handles form data using $\_POST and $\_GET superglobals, with security ensured through validation, sanitization, and secure database interactions.

What is the difference between PHP and ASP.NET?What is the difference between PHP and ASP.NET?Apr 28, 2025 pm 04:56 PM

The article compares PHP and ASP.NET, focusing on their suitability for large-scale web applications, performance differences, and security features. Both are viable for large projects, but PHP is open-source and platform-independent, while ASP.NET,

Is PHP a case-sensitive language?Is PHP a case-sensitive language?Apr 28, 2025 pm 04:55 PM

PHP's case sensitivity varies: functions are insensitive, while variables and classes are sensitive. Best practices include consistent naming and using case-insensitive functions for comparisons.

How do you redirect a page in PHP?How do you redirect a page in PHP?Apr 28, 2025 pm 04:54 PM

The article discusses various methods for page redirection in PHP, focusing on the header() function and addressing common issues like "headers already sent" errors.

Explain type hinting in PHPExplain type hinting in PHPApr 28, 2025 pm 04:52 PM

Article discusses type hinting in PHP, a feature for specifying expected data types in functions. Main issue is improving code quality and readability through type enforcement.

What is PDO in PHP?What is PDO in PHP?Apr 28, 2025 pm 04:51 PM

The article discusses PHP Data Objects (PDO), an extension for database access in PHP. It highlights PDO's role in enhancing security through prepared statements and its benefits over MySQLi, including database abstraction and better error handling.

How to create API in PHP?How to create API in PHP?Apr 28, 2025 pm 04:50 PM

Article discusses creating and securing PHP APIs, detailing steps from endpoint definition to performance optimization using frameworks like Laravel and best security practices.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!