Installing PECL Extensions


  • Applies to: Grid
    • Difficulty: Medium
    • Time Needed: 20
    • Tools Required: SSH, vi knowledge
  • Applies to: DV
    • Difficulty: Medium
    • Time Needed: 20
    • Tools Required: SSH, vi knowledge
  • Applies to: DV
    • Difficulty: Medium
    • Time Needed: 20
    • Tools Required: SSH, vi knowledge

Overview

PECL is a repository for PHP Extensions, providing a directory of all known extensions and hosting facilities for downloading and development of PHP extensions.

READ ME FIRST

This article is provided as a courtesy. Installing, configuring, and troubleshooting third-party applications or code is outside the scope of support provided by (mt) Media Temple. Please take a moment to review the Statement of Support.

Instructions

The following are the steps required to install most PECL extensions on the Grid. You can find a list of PECL extensions at http://pecl.php.net/packages.php.

  1. Connect to your Grid with SSH.
  2. Set your site number variable and current PHP path for later use:
    $ export SITEID=`pwd | awk -F\/ '{ print $3 }'`
    $ export PHPPATH=`php-stable -i | grep "Configure Command" | perl -pe "s/.*'.\/configure'\s*?'--prefix\=(.*?)'.*/\1/"`

    TIP:

    To verify and/or change what version of PHP is being used by your website, please visit the following Community article: How can I specify the PHP version on the Grid?
  3. Create the following directories on your service:
    $ mkdir /home/$SITEID/data/lib
    $ mkdir /home/$SITEID/data/lib/php/
    
  4. Run the command to download and decompress the package, and also navigate within the directory of the package:

    TIP:

    Replace "uploadprogress" with the package you wish to install.
    $ wget http://pecl.php.net/get/uploadprogress && tar zxvf uploadprogress && cd uploadprogress-* && $PHPPATH/bin/phpize
  5. Run the following command to configure the extension:
    $ ./configure --with-php-config=$PHPPATH/bin/php-config
  6. Run the following command to compile the extension and copy it to the following folder:
    $ make && cp modules/*.so /home/$SITEID/data/lib/php
  7. Next, you need to edit your php.ini file to load your PECL extension correctly. Here is an example:

    NOTE:

    Replace "uploadprogress" with the package you wish to install.

    extension_dir=/home/00000/data/lib/php/
    extension = uploadprogress.so
    
  8. Once you save the changes to your php.ini file, the PECL extension should work. You can verify this by looking at your phpinfo page: uploadprogress

CloudTech Can Help!

Installing, configuring, and troubleshooting third-party applications is outside the general scope of support provided by (mt) Media Temple. Please take a moment to review the Statement of Support.

If you're having trouble installing/configuring PECL extensions, additional assistance may be available through our CloudTech service. Our expert engineers can tweak and tune your server for optimum performance. For more information on what CloudTech can do for you, please visit this article.

Instructions

  1. Install the Developer Tools for your DV server.
  2. Log into your server with a root or sudo user via SSH.
  3. Create a temporary executable "/tmp" directory, as shown in steps 1-3 of this article.
  4. Perform a channel-update for PEAR and PECL:
    # pear channel-update pear.php.net
    # pecl channel-update pecl.php.net
  5. Install uploadprogress (or your desired extension).
    # pecl install uploadprogress

    NOTE

    If all goes according to plan, you should see the following output:

    Build process completed successfully
    Installing '/usr/lib64/php/modules/uploadprogress.so'
    install ok: channel://pecl.php.net/uploadprogress-1.X.X.X
    configuration option "php_ini" is not set to php.ini location
    You should add "extension=uploadprogress.so" to php.ini
  6. Remove the temporary executable "/tmp" directory as shown in step 4 of this article.
  7. The module will be installed in /usr/lib64/php/modules/ as /usr/lib64/php/modules/uploadprogress.so.
  8. Add the following line your php.ini:
    extension=uploadprogress.so

    NOTE:

    Place under the "Dynamic Extensions" section!
    If you are using FastCGI, edit the domain's "php.ini" file (i.e. /var/www/vhosts/your_domain/etc/php.ini)!

  9. Reboot Apache:
    # /etc/init.d/httpd restart
  10. Verify the installation of the PHP module by executing the following command:
    # php -m

    Compile from source

    If the above method does not work for you, you'll need to compile the PECL extension from source, which is very easy.

  11. Browse to the directory you'd like the "temp" files to be stored at, in this case /root:
    # cd /root
  12. Next we'll download and extract the actual PECL extension tar.gz file (be sure to replace the PECL extension with the one you want):
    # wget http://pecl.php.net/get/uploadprogress-1.0.3.1.tgz && tar zxvf uploadprogress-1.0.3.1.tgz
  13. Next cd into the new directory and prepare for compiling:
    # phpize && ./configure -with-php-config=/usr/bin/php-config
  14. Once finished we'll compile and install it:
    # make && make install
  15. The module will be installed in /usr/lib64/php/modules/ as /usr/lib64/php/modules/uploadprogress.so.
  16. Add the following line your /etc/php.ini:
    extension=uploadprogress.so

    NOTE:

    Place under the"Dynamic Extensions" section!
    If you are using FastCGI, edit the domain's "php.ini" file (i.e. /var/www/vhosts/your_domain/etc/php.ini)!

  17. Reboot Apache:
    # /etc/init.d/httpd restart