Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Install Several PHP Extensions with PECL over SSH

This guide shows you how to add more than one PHP extension using the PECL tool. You will do it from the command line.

Website Management2 min read10 steps
Note: This guide needs root access. VPS and dedicated server customers have it. Shared hosting usually does not.

What are these words?

PHP is the language many websites use. An extension is a small add-on that gives PHP a new skill, such as talking to a cache. PECL is a store of such add-ons. SSH is a safe way to type commands on your server from your own computer.

Before you start

  • Take a backup or snapshot of your server. Wrong changes can break sites.
  • Find your SSH details in your welcome email, or ask Hostvento support.
  • PECL needs build tools. On many servers you must install a compiler and PHP development files first. Names change by system.

Steps

  1. Open a terminal on your computer. On Windows you can use PowerShell or PuTTY.
  2. Connect to your server. Replace the example with your own details.
    ssh root@your-server-ip
    This logs you in as the root user.
  3. Check that PECL exists.
    pecl version
    This prints the PECL version. If you get an error, install the PHP development package for your system first.
  4. Update the PECL list.
    pecl channel-update pecl.php.net
    This refreshes the list of add-ons.
  5. Install the first extension. This example uses redis.
    pecl install redis
    PECL downloads, builds and installs it. It may ask questions. Pressing Enter accepts the default.
  6. Install the next ones one by one. Examples are imagick and apcu.
    pecl install imagick
    pecl install apcu
    Each command installs one extension.
  7. Tell PHP to load them. Open your php.ini file. Find it with:
    php --ini
    This shows which configuration file PHP uses.
  8. Add one line per extension at the end of the file.
    extension=redis.so
    extension=imagick.so
    extension=apcu.so
  9. Restart your web server so it reads the change. For Apache, this is often:
    systemctl restart httpd
    The service name may be apache2 on some systems.
  10. Check the result.
    php -m | grep -i -E "redis|imagick|apcu"
    This lists the extensions that PHP loaded.
Tip: If a build fails, read the last lines of the error. It often names a missing package. Install it and try again.

Quick recap

  • PECL installs PHP add-ons from the command line.
  • You need root access and build tools.
  • Run pecl install name for each extension.
  • Add extension=name.so to php.ini and restart the web server.
  • Check with php -m.