快速自動安裝php擴充模組的方法

來源:互聯網
上載者:User
  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
複製代碼

已經安裝成功。後記:其它也有源碼安裝,上pecl.php.net 找到對應源碼包解壓。可以通過:pecl install 源碼檔案。

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.