Home Backend Development PHP Tutorial How to quickly and automatically install php extension modules

How to quickly and automatically install php extension modules

Jul 25, 2016 am 09:04 AM

  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 of this Website
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

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

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

How does session hijacking work and how can you mitigate it in PHP? How does session hijacking work and how can you mitigate it in PHP? Apr 06, 2025 am 12:02 AM

Session hijacking can be achieved through the following steps: 1. Obtain the session ID, 2. Use the session ID, 3. Keep the session active. The methods to prevent session hijacking in PHP include: 1. Use the session_regenerate_id() function to regenerate the session ID, 2. Store session data through the database, 3. Ensure that all session data is transmitted through HTTPS.

Describe the SOLID principles and how they apply to PHP development. Describe the SOLID principles and how they apply to PHP development. Apr 03, 2025 am 12:04 AM

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to debug CLI mode in PHPStorm? How to debug CLI mode in PHPStorm? Apr 01, 2025 pm 02:57 PM

How to debug CLI mode in PHPStorm? When developing with PHPStorm, sometimes we need to debug PHP in command line interface (CLI) mode...

What are Enumerations (Enums) in PHP 8.1? What are Enumerations (Enums) in PHP 8.1? Apr 03, 2025 am 12:05 AM

The enumeration function in PHP8.1 enhances the clarity and type safety of the code by defining named constants. 1) Enumerations can be integers, strings or objects, improving code readability and type safety. 2) Enumeration is based on class and supports object-oriented features such as traversal and reflection. 3) Enumeration can be used for comparison and assignment to ensure type safety. 4) Enumeration supports adding methods to implement complex logic. 5) Strict type checking and error handling can avoid common errors. 6) Enumeration reduces magic value and improves maintainability, but pay attention to performance optimization.

How to automatically set permissions of unixsocket after system restart? How to automatically set permissions of unixsocket after system restart? Mar 31, 2025 pm 11:54 PM

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

See all articles