What are PHP extensions

PHP extensions are compiled libraries which enable specific functions to be used in your PHP code. For example, you want to interact with MySQL using PHP. You can implement your own methods to connect to MySQL server, make queries using TCP/IP protocol.

Available PHP extensions

The following is a list of PHP extensions enabled by default in vpsmodel's PHP builds. These extensions are available in PHP 5.4, 5.5, 5.6, 7.0, 7.1, 7.2, 7.3, and 7.4.
bcmathbz2calendarcgi-fcgiCorectypecurldatedomereg [Removed in PHP 7.0, replaced by pcre.]exiffileinfofilterftpgd [WebP support added in PHP 7.0.]gettextgmp [Added in PHP 7.0.]hashiconvimapintljsonldap [Added in PHP 7.0.]libsodium [Added in PHP 7.2]libxmlmbstringmcrypt [Removed in PHP 7.2, replaced by sodium.]mysql [Removed in PHP 7.0, replaced by mysqli.]mysqlimysqlndodbcopensslpcntlpcrePDOpdo_dblib [Added in PHP 7.0.]pdo_mysqlpdo_odbcpdo_pgsqlpdo_sqlitepgsqlPharposixreadlineReflectionsessionshmopSimpleXMLsnmpsoapsocketssodiumSPLsqlite3standardtidytokenizerxmlxmlreaderxmlrpc [Added in PHP 7.0.]xmlwriterxslZend OPcache [Added in PHP 5.5.]zip [Not supported in PHP 7.4 on Ubuntu 14.04]zlib

Here you will find information about customizing the PHP Configuration.

Also have a look at how to install PHP PECL extensions.

How to remove PHP extensions

If you no longer need third-party PHP extensions you've installed, you can remove them.

In the examples shown, replace "X.Y" with your app's PHP version(for example, "7.2").

Remove the Extension's Configuration File

To remove a PHP extension, SSH into your server as root and run the following command. Replace EXTENSION with the name of the extension to remove.

sudo rm /etc/phpX.Y-sp/conf.d/EXTENSION.ini

Next, restart PHP-FPM with the command:

sudo service phpX.Y-fpm-sp restart

If the extension was installed on multiple PHP versions, repeat the above steps for each PHP version.

Optional: Remove the Extension's Library File

Once you've removed the extension's configuration file, you can choose to remove the extension's library file.

You do not need to remove the library file. As long as you've removed the configuration file as shown above, the extension is removed from PHP.

Removing a Library File Installed through PECL

To remove the library file for an extension installed through PECL, run the following command as root. Replace EXTENSION with the name of the extension.

sudo peclX.Y-sp uninstall EXTENSION

The output of the above command will include the following message:

Unable to remove "extension=EXTENSION.so" from php.ini

This is normal. You've already removed the configuration file as shown above so you can ignore this.

Finally, restart PHP to make sure there are no errors.

sudo service phpX.Y-fpm-sp restart

If you did not correctly remove the extension's configuration file, restarting PHP will show warnings.

Removing a Library File Installed Manually

If the extension was not installed through PECL, for example if the extension was pre-built or installed with make install, delete the extension's library file with the following command. Replace EXTENSION with the name of the extension.

sudo rm /opt/sp/phpX.Y/lib/php/extensions/no-debug-non-zts-*/EXTENSION.so

If you did not correctly remove the extension's configuration file, restarting PHP will show warnings.

How to install ionCube loader

The ionCube Loader is a PHP extension that enables PHP to execute files encoded using the ionCube Encoder.In this tutorial, we'll show you how to install the ionCube Loader on your servers.

This tutorial assumes you are already running a server with vpsmodel.
If you have already installed the ionCube Loader for a different version of PHP,please remove the old tarball from the server so the names in this tutorial match what is present on the server.

Remove Previous Versions

The following commands will delete previous versions of ioncube_loader tarballs located in /usr/local:

cd /usr/localsudo rm ioncube_loaders*.tar.gz

Download, Extract, and Configure

To install the ionCube Loader, SSH in to yourserver as the root user and run the following commands for the PHPversion you're adding the ionCube loader to.

PHP 7.3
cd /usr/localsudo wget https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gzsudo tar xzf ioncube_loaders_lin_x86-64.tar.gzsudo cp ioncube/ioncube_loader_lin_7.3.so /opt/sp/php7.3/lib/php/extensions/no-debug-non-zts-20180731/sudo bash -c 'echo "zend_extension=/opt/sp/php7.3/lib/php/extensions/no-debug-non-zts-20180731/ioncube_loader_lin_7.3.so" > /etc/php7.3-sp/conf.d/20ioncube.ini'sudo service php7.3-fpm-sp restart
PHP 7.2
cd /usr/localsudo wget https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gzsudo tar xzf ioncube_loaders_lin_x86-64.tar.gzsudo cp ioncube/ioncube_loader_lin_7.2.so /opt/sp/php7.2/lib/php/extensions/no-debug-non-zts-20170718/sudo bash -c 'echo "zend_extension=/opt/sp/php7.2/lib/php/extensions/no-debug-non-zts-20170718/ioncube_loader_lin_7.2.so" > /etc/php7.2-sp/conf.d/20ioncube.ini'sudo service php7.2-fpm-sp restart
PHP 7.1
cd /usr/localsudo wget https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gzsudo tar xzf ioncube_loaders_lin_x86-64.tar.gzsudo cp ioncube/ioncube_loader_lin_7.1.so /opt/sp/php7.1/lib/php/extensions/no-debug-non-zts-20160303/sudo bash -c 'echo "zend_extension=/opt/sp/php7.1/lib/php/extensions/no-debug-non-zts-20160303/ioncube_loader_lin_7.1.so" > /etc/php7.1-sp/conf.d/20ioncube.ini'sudo service php7.1-fpm-sp restart
PHP 7.0
cd /usr/localsudo wget https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gzsudo tar xzf ioncube_loaders_lin_x86-64.tar.gzsudo cp ioncube/ioncube_loader_lin_7.0.so /opt/sp/php7.0/lib/php/extensions/no-debug-non-zts-20151012/sudo bash -c 'echo "zend_extension=/opt/sp/php7.0/lib/php/extensions/no-debug-non-zts-20151012/ioncube_loader_lin_7.0.so" > /etc/php7.0-sp/conf.d/20ioncube.ini'sudo service php7.0-fpm-sp restart

Verifying ionCube Loader Is Installed

In the commands shown, replace "X.Y" with your app's PHP version(for example, "7.0" or "7.1").
cd /usr/localsudo wget https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gzsudo tar xzf ioncube_loaders_lin_x86-64.tar.gzsudo cp ioncube/ioncube_loader_lin_7.0.so /opt/sp/php7.0/lib/php/extensions/no-debug-non-zts-20151012/sudo bash -c 'echo "zend_extension=/opt/sp/php7.0/lib/php/extensions/no-debug-non-zts-20151012/ioncube_loader_lin_7.0.so" > /etc/php7.0-sp/conf.d/20ioncube.ini'sudo service php7.0-fpm-sp restart

You can verify the ionCube Loader extension is installed correctly by runningthis command:

phpX.Y-sp -i | grep -i ioncube

You should see output like the following:

Additional .ini files parsed => /etc/phpX.Y-sp/conf.d/20ioncube.ini,
    with the ionCube PHP Loader (enabled) + Intrusion Protection from ioncube24.com (unconfigured) v10.0.0 (), Copyright (c) 2002-2017, by ionCube Ltd.
ionCube Loader

Uninstalling IonCube Loader

In the commands shown, replace "X.Y" with your app's PHP version(for example, "7.0" or "7.1").

To remove ionCube loader from a PHP version you had previously installed iton, run the following commands as root.

sudo rm /etc/phpX.Y-sp/conf.d/20ioncube.inisudo service phpX.Y-fpm-sp restart

How to Install the PHP Memcached Extension

In the examples shown, replace "X.Y" with your app's PHP version (for example, "7.1" or "5.6"). To install a PECL extension for multiple PHP versions, repeat the PECL extension installation for each PHP version.
These PHP extensions provide client access to the Memcached server. They are not the Memcached server itself.You also need to install the Memcached server to use Memcached with your PHP apps.

Memcached

Installing Memcached on PHP 7.0, 7.1, 7.2, 7.3, and 7.4

On Ubuntu 12.04, the memcached extension can't be installed for PHP 7.If your server is running Ubuntu 12.04, you'll need to use PHP 5.6.See below for PHP 5.6 instructions.

To install this extension for PHP 7.X, SSH in to your server as rootand run the following commands:

sudo apt-get -y install gcc make autoconf libc-dev pkg-configsudo apt-get -y install zlib1g-devsudo apt-get -y install libmemcached-devsudo pecl7.X-sp install memcached

When you are shown the prompt

libmemcached directory [no] :

type or paste the following text exactly as shown and press Enter.

no --disable-memcached-sasl

That is, the entire line you'll see on your screen will be as follows onceyou press Enter.

libmemcached directory [no] : no --disable-memcached-sasl

Once installed, create a configuration file for the extension and restartPHP by running the following commands as root

sudo bash -c "echo extension=memcached.so > /etc/php7.X-sp/conf.d/memcached.ini"sudo service php7.X-fpm-sp restart

Memcache

Two different extensions areavailable that provide access to Memcached from within your PHPscripts.One is named memcache and the other is named memcached.This extension (the one named memcache with no d on the end)is no longer maintained.
For instructions on the memcachedextension (with a d on the end), see the section above.

To install this extension, SSH in to yourserver as root and run the following command:

sudo apt-get install gcc make autoconf libc-dev pkg-configsudo apt-get install zlib1g-devsudo pecl5.X-sp install memcache

Once installed, create a configuration file for the extension and restart PHP.

sudo bash -c "echo extension=memcache.so > /etc/php5.X-sp/conf.d/memcache.ini"sudo service php5.X-fpm-sp restart

The memcache extension does not support PHP 7.For PHP 7 support, use the memcached extension shown above.

How to Install the PHP ImageMagick Extension (IMagick)

In the examples shown, replace "X.Y" with your app's PHP version(for example, "5.4" or "7.0").To install a PECL extension for multiple PHP versions, repeat the PECL extension installation for each PHP version.

The ImageMagick extension supports PHP 5.4, 5.5, 5.6, 7.0, 7.1, 7.2, 7.3, and 7.4.

Imagick: The PHP ImageMagick Extension

The ImageMagick extension, called Imagick when referring to the PHP extension, is a nativePHP extension to create and modify images using the ImageMagick API.

To install this extension, run the following commands as your server'sroot user:

sudo apt-get -y install gcc make autoconf libc-dev pkg-configsudo apt-get -y install libmagickwand-devsudo peclX.Y-sp install imagick

When prompted with:

Please provide the prefix of Imagemagick installation [autodetect] :

just press Enter; do not type a prefix (that is, allow autodetect).

Once installed, create a configuration file for the extension and restartPHP by running the following commands as root:

sudo bash -c "echo extension=imagick.so > /etc/phpX.Y-sp/conf.d/imagick.ini"sudo service phpX.Y-fpm-sp restart

Using Imagick with PDF Files

ImageMagick was not designed to securely handle untrusted PDF files.Enabling PDF file handling as shown below is dangerous if any malicious PDF filesare ever processed.

Additionally, attempting to work around ImageMagick's PDF security issues by using Ghostscriptdirectly is also dangerous as Ghostscript is also vulnerable to exploitationwhen processing malicious PDF files.

In order to allow ImageMagick to process PDF files,you must SSH into your server as root and edit the following file:

/etc/ImageMagick-6/policy.xml

Locate the line:

Comment out this line by replacing it with the following:

Finally, restart PHP:

sudo service phpX.Y-fpm-sp restart

Verifying the Installation

You can verify the ImageMagick extension is installed with this command:

phpX.Y-sp -i | grep imagick

If ImageMagick is installed correctly, you will see the following:

/etc/phpX.Y-sp/conf.d/imagick.ini,imagickimagick module=> enabledimagick module version=> 3.4.3RC1imagick classes=> Imagick, ImagickDraw, ImagickPixel, ImagickPixelIteratorImagick compiled with ImageMagick version=> ImageMagick 6.6.9-7 2016-06-01 Q16 http://www.imagemagick.orgImagick using ImageMagick library version=> ImageMagick 6.6.9-7 2016-06-01 Q16 http://www.imagemagick.orgimagick.locale_fix=> 0=> 0imagick.progress_monitor=> 0=> 0imagick.skip_version_check=> 0=> 0

Uninstalling the ImageMagick Extension

To uninstall this extension, as root run the commands:

sudo rm /etc/phpX.Y-sp/conf.d/imagick.inisudo peclX.Y-sp uninstall imagick

Next, restart PHP-FPM with the command:

sudo service phpX.Y-fpm-sp restart

How to Install SourceGuardian

In this tutorial, we'll show you how to install theSourceGuardian PHP encoderon your servers.

This tutorial assumes you have alreadylaunched a vpsmodel server.

Download, Extract, and Configure

To install SourceGuardian, SSH in to yourserver as the root user and run the following commands for the PHPversion you're adding SourceGuardian to.

PHP 7.0

sudo mkdir /usr/local/sourceguardiancd /usr/local/sourceguardiansudo wget http://www.sourceguardian.com/loaders/download/loaders.linux-x86_64.tar.gzsudo tar xzf loaders.linux-x86_64.tar.gzsudo cp ixed.7.0.lin /opt/sp/php7.0/lib/php/extensions/no-debug-non-zts-20151012/sudo bash -c 'echo "zend_extension=/opt/sp/php7.0/lib/php/extensions/no-debug-non-zts-20151012/ixed.7.0.lin" > /etc/php7.0-sp/conf.d/sourceguardian.ini'sudo service php7.0-fpm-sp restart

PHP 7.1

sudo mkdir /usr/local/sourceguardiancd /usr/local/sourceguardiansudo wget http://www.sourceguardian.com/loaders/download/loaders.linux-x86_64.tar.gzsudo tar xzf loaders.linux-x86_64.tar.gzsudo cp ixed.7.1.lin /opt/sp/php7.1/lib/php/extensions/no-debug-non-zts-20160303/sudo bash -c 'echo "zend_extension=/opt/sp/php7.1/lib/php/extensions/no-debug-non-zts-20160303/ixed.7.1.lin" > /etc/php7.1-sp/conf.d/sourceguardian.ini'sudo service php7.1-fpm-sp restart

PHP 7.2

sudo mkdir /usr/local/sourceguardiancd /usr/local/sourceguardiansudo wget http://www.sourceguardian.com/loaders/download/loaders.linux-x86_64.tar.gzsudo tar xzf loaders.linux-x86_64.tar.gzsudo cp ixed.7.2.lin /opt/sp/php7.2/lib/php/extensions/no-debug-non-zts-20170718/sudo bash -c 'echo "zend_extension=/opt/sp/php7.2/lib/php/extensions/no-debug-non-zts-20170718/ixed.7.2.lin" > /etc/php7.2-sp/conf.d/sourceguardian.ini'sudo service php7.2-fpm-sp restart

PHP 7.3

SourceGuardian does not yet support PHP 7.3.

Verifying the Installation

You can verify SourceGuardian is installed correctly by running the command:

phpX.Y-sp -i | grep SourceGuardian

You should see output like the following:

    with SourceGuardian v11.1.1, Copyright (c) 2000-2017, by SourceGuardian Ltd.
SourceGuardian
SourceGuardian Loader Support => enabled
SourceGuardian Loader Version => 11.1.1
SourceGuardian Loader Build Number => 0x00000019

Uninstalling the SourceGuardian Extension

To uninstall this extension, as root run the command:

sudo rm /etc/phpX.Y-sp/conf.d/sourceguardian.ini

Next, restart PHP-FPM with the command:

sudo service phpX.Y-fpm-sp restart

How to Install the PHP AMQP Extension

To install a PECL extension for multiple PHP versions, repeat thePECL extension installation for each PHP version.
The PHP AMQP extension requires Ubuntu 16.04 or 18.04.This extension will not work on Ubuntu 14.04 as the extension requires anewer version of the librabbitmq library than Ubuntu supports on 14.04.

The PHP AMQP extensionprovides PHP functions for communicating with AMQP-compatible servers, suchas RabbitMQ.

Installing the AMQP Extension on PHP 7.3 or 7.4

The AMQP extension does not yet support PHP 7.3 or 7.4.

Installing the AMQP Extension on PHP 5 through 7.2

In the examples shown, replace "X.Y" with your app's PHP version(for example, "7.0").

To install the PHP AMQP extension,SSH in to your server as root andfirst run the following commands:

sudo apt-get -y install gcc make autoconf libc-dev pkg-configsudo apt-get -y install libssl-devsudo apt-get -y install librabbitmq-dev

Next, run the following command:

sudo peclX.Y-sp install amqp

When you receive this prompt:

Set the path to librabbitmq install prefix [autodetect] :

press Enter without entering a prefix.This allows the library's location to be autodetected.

Once installed, create a configuration file for the extension and restartPHP by running the following command as root:

sudo bash -c "echo extension=amqp.so > /etc/phpX.Y-sp/conf.d/amqp.ini"sudo service phpX.Y-fpm-sp restart

Verifying the PHP AMQP Extension Is Installed

You can verify the AMQP extension is installed by running this command:

phpX.Y-sp -i | grep -i amqp

You should see output similar to the following:

Additional .ini files parsed=> /etc/php7.1-sp/conf.d/amqp.ini,amqpAMQP protocol version=> 0-9-1amqp.auto_ack=> 0=> 0amqp.channel_max=> 256=> 256amqp.connect_timeout=> 0=> 0amqp.frame_max=> 131072=> 131072amqp.heartbeat=> 0=> 0amqp.host=> localhost=> localhostamqp.login=> guest=> guestamqp.password=> guest=> guestamqp.port=> 5672=> 5672amqp.prefetch_count=> 3=> 3amqp.read_timeout=> 0=> 0amqp.timeout=> no value=> no valueamqp.vhost=> /=> /amqp.write_timeout=> 0=> 0

Uninstalling the AMQP Extension

To uninstall this extension, as root run the commands:

sudo rm /etc/phpX.Y-sp/conf.d/amqp.inisudo peclX.Y-sp uninstall amqp

Next, restart PHP-FPM with the command:

sudo service phpX.Y-fpm-sp restart

How to Install the PHP APCu Backwards Compatibility Extension

In the examples shown, replace "7.X" with your app's PHP version(for example, "7.0" or "7.1").

The APCu BackwardsCompatibility (apcu-bc) module extends the APCu module to add fullbackwards compatibility with APC for PHP 7.0, 7.1, and 7.2.

The reason apcu-bc exists is because starting with PHP 7.0,APCu removed the option for full backwards compatibility with APCthat existed with APCu in PHP 5.5 and 5.6.

Installing apcu-bc on PHP 7.0, 7.1, 7.2, 7.3, and 7.4

To install apcu-bc, you must firstinstall APCu.If you have not installed APCu, you won't be able to install apcu-bc.

Next, SSH in to your server as root and run the following commands:

sudo apt-get -y install gcc make autoconf libc-dev pkg-configsudo pecl7.X-sp install apcu_bc

Once installed, create a configuration file for the extension and restartPHP by running the following commands as root:

sudo bash -c "echo extension=apc.so > /etc/php7.X-sp/conf.d/z_apc.ini"sudo service php7.X-fpm-sp restart
The configuration file is namedz_apc.ini because the apcu-bc extension must be loaded after theAPCu extension.

Installing apcu-bc on PHP 5.4, 5.5, and 5.6

The apcu-bc extension is not relevant to PHP versions before PHP 7.0.For PHP 5.4, only the APC extension is relevant.For PHP 5.5 and 5.6, only the APCu extension is relevant.

Verifying the Installation

You can verify apcu-bc is installed correctly by running this command:

php7.X-sp -i | grep -i "APC Compatibility"

You should see output like the following:

APC Compatibility=> 1.0.3

Uninstalling the apcu-bc Extension

To uninstall this extension, as root run the commands:

sudo rm /etc/phpX.Y-sp/conf.d/z_apc.inisudo peclX.Y-sp uninstall apcu_bc

Next, restart PHP-FPM with the command:

sudo service phpX.Y-fpm-sp restart

How to Install the PHP APCu Extension

In the examples shown, replace "X.Y" with your app's PHP version(for example, "5.6" or "7.1").

The APCu extension addsobject caching functionsto PHP.

APCu is the official replacement for the outdated APC extension.APC provided both opcode caching (opcache) and object caching.As PHP versions 5.5 and above include their own opcache, APC wasno longer compatible, and its opcache functionality became useless.The developers of APC then created APCu, which offers only theobject caching functionality (they removed the outdated opcache).

Installing APCu on PHP 7.0, 7.1, 7.2, 7.3, and 7.4

To install this extension on PHP 7.X, SSH in to your server as rootand run these commands:

sudo apt-get -y install gcc make autoconf libc-dev pkg-configsudo pecl7.X-sp install apcu

When asked the following question, press Enter.

Enable internal debugging in APCu [no] :

Once installed, create a configuration file for the extension and restartPHP by running the following commands as root

sudo bash -c "echo extension=apcu.so > /etc/php7.X-sp/conf.d/apcu.ini"sudo service php7.X-fpm-sp restart
APCu for PHP 7+ does not support an optionfor full backwards compatibility with APC.If you require full backwards compatibility with APC and you're usingPHP 7+, you'll also need to install theAPCuBackwards Compatibility (apcu-bc) extension.

Installing APCu on PHP 5.4, 5.5, and 5.6

To install this extension on PHP 5.X, SSH into your server as root and run these commands:

sudo apt-get -y install gcc make autoconf libc-dev pkg-configsudo pecl5.X-sp install apcu-4.0.11

When asked the following questions, press Enter.

Enable full APC compatibility [yes] :Enable internal debugging in APCu [no] :

Once installed, create a configuration file for the extension and restartPHP by running the following command as root:

sudo bash -c "echo extension=apcu.so > /etc/php5.X-sp/conf.d/apcu.ini"sudo service php5.X-fpm-sp restart

Verifying the Installation

You can verify APCu is installed correctly by running the command:

phpX.Y-sp -i | grep apcu

You should see output like the following:

Additional .ini files parsed=> /etc/phpX.Y-sp/conf.d/apcu.ini,apcu

Uninstalling the APCu Extension

To uninstall this extension, as root run the commands:

sudo rm /etc/phpX.Y-sp/conf.d/apcu.inisudo peclX.Y-sp uninstall apcu

Next, restart PHP-FPM with the command:

sudo service phpX.Y-fpm-sp restart

How to Install the PHP GeoIP Extension

In the examples shown, replace "X.Y" with your app's PHP version(for example, "7.1").To install a PECL extension for multiple PHP versions, repeat thePECL extension installation for each PHP version.

The GeoIP extensionallows you to find the location of an IP address,including the city, state, country, latitude, and longitude.

If you'd like to use the new GeoIP2, MaxMind now offers a pure PHPimplementation that doesn't require a C extension:https://github.com/maxmind/GeoIP2-php.

Installing GeoIP on PHP 7.X

To install this extension on PHP 7.0, 7.1, 7.2, 7.3, or 7.4, run the followingcommands as your server's root user:

sudo apt-get -y install gcc make autoconf libc-dev pkg-configsudo apt-get -y install libgeoip-devsudo pecl7.X-sp install geoip-beta

Once installed, create a configuration file for the extension and restartPHP by running the following command as root:

sudo bash -c "echo extension=geoip.so > /etc/php7.X-sp/conf.d/geoip.ini"sudo service php7.X-fpm-sp restart

Installing GeoIP on PHP 5.X

To install this extension on PHP 5.4, 5.5, or 5.6, run the followingcommands as your server's root user:

sudo apt-get -y install gcc make autoconf libc-dev pkg-configsudo apt-get -y install libgeoip-devsudo pecl5.X-sp install geoip

Once installed, create a configuration file for the extension and restartPHP by running the following command as root:

sudo bash -c "echo extension=geoip.so > /etc/php5.X-sp/conf.d/geoip.ini"sudo service php5.X-fpm-sp restart

Verifying GeoIP Is Installed

You can check that the extension was installed with this command:

phpX.Y-sp -i | grep geoip

The output will look like this:

$ php7.1-sp -i | grep geoip/etc/php7.1-sp/conf.d/geoip.ini,geoipgeoip support=> enabledgeoip extension version=> 1.1.1geoip library version=> 1006000geoip.custom_directory=> no value=> no value

Uninstalling the GeoIP Extension

To uninstall this extension, as root run the commands:

sudo rm /etc/phpX.Y-sp/conf.d/geoip.inisudo peclX.Y-sp uninstall geoip

Next, restart PHP-FPM with the command:

sudo service phpX.Y-fpm-sp restart

How to Install the PHP GnuPG Extension

In the examples shown, replace "X.Y" with your app's PHP version(for example, "7.1").To install a PECL extension for multiple PHP versions, repeat thePECL extension installation for each PHP version.

The GnuPG extensionallows you to encrypt and sign your data and communication while featuringa versatile key management system. GnuPG also allows you access to modulesfor many public key directories.

Installing GnuGP on PHP

As a PECL extension, GnuGP is installed using the peclX.Y-spcommand, replacing "X.Y" the version of PHP running your app.If you have multiple apps using multiple versions of PHP, you will need tofollow these instructions for each version of PHP.

To install the GnuGP extension on PHP 5.4 through PHP 7.4, run the followingcommands as your server's root user:

sudo apt-get -y install gcc make autoconf libc-dev pkg-configsudo apt-get -y install libgpgme11-dev
sudo peclX.Y-sp install gnupgsudo bash -c "echo extension=gnupg.so > /etc/phpX.Y-sp/conf.d/gnupg.ini"sudo service phpX.Y-fpm-sp restart

Verifying GnuPG Is Installed

Confirm the installation worked by running this command:

phpX.Y-sp -i | grep -i gnupg

If the installation was successful, you will see output like the following:

/etc/php7.0-sp/conf.d/gnupg.ini,gnupggnupg support=> enabled

Uninstalling the GnuPG Extension

To uninstall this extension, as root run the commands:

sudo rm /etc/phpX.Y-sp/conf.d/gnupg.inisudo peclX.Y-sp uninstall gnupg

Next, restart PHP-FPM with the command:

sudo service phpX.Y-fpm-sp restart

How to Install the PHP gRPC Extension

In the examples shown, replace "X.Y" with your app's PHP version(for example, "5.6" or "7.2").To install a PECL extension for multiple PHP versions, repeat thePECL extension installation for each PHP version.
The gRPC extension requires Ubuntu 14.04, 16.04, or 18.04.This extension can't be installed on Ubuntu 12.04.

gRPC

Google's gRPC is a remote procedure call (RPC)system that communicates over HTTP/2, usesProtocol Buffersto serialize data, works across programming languages, and provides manyother features such as pluggable authentication.

Installing gRPC on PHP 5.5+ or PHP 7.0 through PHP 7.4

To install this extension, run the following commands as yourserver's root user:

sudo apt-get -y install gcc g++ make autoconf libc-dev pkg-configsudo apt-get -y install zlib1g-devsudo peclX.Y-sp install grpc

Once installed, create a configuration file for the extension and restartPHP by running the following commands as root:

sudo bash -c "echo extension=grpc.so > /etc/phpX.Y-sp/conf.d/grpc.ini"sudo service phpX.Y-fpm-sp restart

Installing gRPC on PHP 5.4

The gRPC extension does not support PHP 5.4.

Verifying the Installation

You can verify the gRPC extension is installed correctly by runningthis command:

phpX.Y-sp -i | grep -i grpc

You should see output like the following:

grpcgrpc support=> enabledgrpc module version=> 1.9.0

Uninstalling the gRPC Extension

To uninstall this extension, as root run the commands:

sudo rm /etc/phpX.Y-sp/conf.d/grpc.inisudo peclX.Y-sp uninstall grpc

Next, restart PHP-FPM with the command:

sudo service phpX.Y-fpm-sp restart

How to Install the PHP Mailparse Extension

In the examples shown, replace "X.Y" with your app's PHP version(for example, "5.6" or "7.0").To install this extension for multiple PHP versions, repeat theinstallation for each PHP version.

The PHP mailparse extensionprovides functions for parsing and working with email messages.It can deal with RFC 822 and RFC 2045 (MIME) compliant messages.Mailparse is stream-based, meaning it does not keep in-memory copies of thefiles it processes and so is very resource efficient when dealing with large messages.

Install Mailparse on PHP 7.3 and 7.4

The mailparse extension does not yet support PHP 7.3 or 7.4.

Install Mailparse on PHP 7.0, 7.1, or 7.2

To install this extension on PHP 7.X, SSH in to your server as root andrun the following commands:

sudo apt-get -y install gcc make autoconf libc-dev pkg-configsudo pecl7.X-sp install --nodeps mailparsesudo bash -c "echo extension=mailparse.so > /etc/php7.X-sp/conf.d/mailparse.ini"sudo service php7.X-fpm-sp restart

Install Mailparse on PHP 5.4, 5.5, or 5.6

To install this extension on PHP 5.X, SSH into your server as root and run the following commands:

sudo apt-get -y install gcc make autoconf libc-dev pkg-configsudo pecl5.X-sp install --nodeps mailparse-2.1.6sudo bash -c "echo extension=mailparse.so > /etc/php5.X-sp/conf.d/mailparse.ini"sudo service php5.X-fpm-sp restart

Verify the Installation

You can verify the mailparse extension is installed by running this command:

phpX.Y-sp -i | grep mailparse

You should see output such as the following:

/etc/phpX.Y-sp/conf.d/mailparse.ini,mailparsemailparse support=> enabledmailparse.def_charset=> us-ascii=> us-ascii

Uninstalling the MailParse Extension

To uninstall this extension, as root run the commands:

sudo rm /etc/phpX.Y-sp/conf.d/mailparse.inisudo peclX.Y-sp uninstall mailparse

Next, restart PHP-FPM with the command:

sudo service phpX.Y-fpm-sp restart

How to Install the PHP mcrypt Extension

In the examples shown, replace "X.Y" with your app's PHP version(for example, "7.2").

The mcrypt extensionis an interface to the mcrypt cryptography library.This extension is useful for allowing PHP code using mcrypt to run on PHP 7.2+.

The mcrypt extension is included in PHP 5.4 through PHP 7.1.It was removed from PHP 7.2 and moved to an unofficial PECL extensionbecause the mcrypt library is no longer maintained.

For PHP 7.2+, PHP instead useslibsodiumas a cryptography library.ServerPilot builds PHP 7.2+ with the official libsodium extension.New PHP code should be written to use libsodium rather than mcrypt.

Installing mcrypt on PHP 5, PHP 7.0, and PHP 7.1

You do not need to install the mcrypt extension on PHP 5, 7.0, or 7.1.ServerPilot builds these PHP versions with the mcrypt extension so itis always available.

Installing mcrypt on PHP 7.2, 7.3, or 7.4

To install this extension on PHP 7.2 through 7.4, run the followingcommands as your server's root user:

sudo apt-get -y install gcc make autoconf libc-dev pkg-configsudo apt-get -y install libmcrypt-devsudo pecl7.2-sp install --nodeps mcrypt-snapshot

When you are shown the prompt

libmcrypt prefix? [autodetect] :

Press Enter to autodetect.

Once installed, create a configuration file for the extension and restartPHP by running the following commands as root:

sudo bash -c "echo extension=mcrypt.so > /etc/php7.2-sp/conf.d/mcrypt.ini"sudo service php7.2-fpm-sp restart

Verifying mcrypt Is Installed

You can check that the extension was installed with this command:

php7.2-sp -i | grep mcrypt

The output will look like this:

$ php7.2-sp -i | grep mcrypt/etc/php7.2-sp/conf.d/mcrypt.ini,Registered Stream Filters=> zlib.*, convert.iconv.*, bzip2.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk, mcrypt.*, mdecrypt.*mcryptmcrypt support=> enabledmcrypt_filter support=> enabledmcrypt.algorithms_dir=> no value=> no valuemcrypt.modes_dir=> no value=> no value

Uninstalling the Mcrypt Extension

To uninstall this extension, as root run the commands:

sudo rm /etc/phpX.Y-sp/conf.d/mcrypt.inisudo peclX.Y-sp uninstall mcrypt

Next, restart PHP-FPM with the command:

sudo service phpX.Y-fpm-sp restart

How to Install the PHP MongoDB Extension

In the examples shown, replace "X.Y" with your app's PHP version(for example, "7.0").To install a PECL extension for multiple PHP versions, repeat thePECL extension installation for each PHP version.
This PHP extension provides clientaccess to the MongoDB server.It is not MongoDB itself.MongoDB is a NoSQL database server.When you install the mongo PHP extension, it will allow PHP to communicatewith a MongoDB server.

The MongoDB PHP extension supports PHP 5.4, 5.5, 5.6, 7.0, 7.1, 7.2, and 7.3.

Installing the MongoDB Extension

To install this extension, run the following commands as your server'sroot user:

sudo apt-get -y install gcc make autoconf libc-dev pkg-configsudo apt-get -y install libssl-devsudo peclX.Y-sp install mongodb

Once installed, create a configuration file for the extension and restartPHP by running the following commands as root:

sudo bash -c "echo extension=mongodb.so > /etc/phpX.Y-sp/conf.d/mongodb.ini"sudo service phpX.Y-fpm-sp restart

Verify the Installation

You can verify the MongoDB extension is installed by running this command:

phpX.Y-sp -i | grep -i mongodb

You should see output such as the following:

/etc/phpX.Y-sp/conf.d/mongodb.ini,mongodbmongodb support=> enabledmongodb version=> 1.1.8mongodb stability=> stablemongodb.debug=> no value=> no value

Uninstalling the MongoDB Extension

To uninstall this extension, as root run the commands:

sudo rm /etc/phpX.Y-sp/conf.d/mongodb.inisudo peclX.Y-sp uninstall mongodb

Next, restart PHP-FPM with the command:

sudo service phpX.Y-fpm-sp restart

Using the MongoDB PHP Library

Once you've installed the mongodb PHP extension, the easiest wayto use the extension is through the MongoDB PHP library.

See the PHP documentation for atutorial on usingthe MongoDB PHP library.

Removing the Deprecated mongo PHP Extension

If you previously installed the older mongo extension(the mongo extension is different than the mongodb extension),you can remove it with the following commands run as root:

sudo rm /etc/phpX.Y-sp/conf.d/mongo.inisudo service phpX.Y-fpm-sp restart

How to Install the PHP OAuth Extension

In the examples shown, replace "5.X" or "7.X" with your app's PHP version(for example, "5.4" or "7.1").To install a PECL extension for multiple PHP versions, repeat thePECL extension installation for each PHP version.

OAuth

The OAuth extensionprovides OAuth consumer and provider bindings.OAuth is an authorization protocol built on top of HTTP which allows applicationsto securely access data without having to store usernames and passwords.

Installing OAuth on PHP 7.0, 7.1, 7.2, or 7.3

To install this extension on PHP 7.X, run the following commands as yourserver's root user:

sudo apt-get -y install gcc make autoconf libc-dev pkg-configsudo pecl7.X-sp install oauth

Once installed, create a configuration file for the extension and restartPHP by running the following commands as root:

sudo bash -c "echo extension=oauth.so > /etc/php7.X-sp/conf.d/oauth.ini"sudo service php7.X-fpm-sp restart

Installing OAuth on PHP 5.4, 5.5, or 5.6

To install this extension on PHP 5.X, run the following commands as yourserver's root user:

sudo apt-get -y install gcc make autoconf libc-dev pkg-configsudo pecl5.X-sp install oauth-1.2.3

Once installed, create a configuration file for the extension and restartPHP by running the following commands as root:

sudo bash -c "echo extension=oauth.so > /etc/php5.X-sp/conf.d/oauth.ini"sudo service php5.X-fpm-sp restart

Verifying the Installation

You can verify the oauth extension is installed correctly by runningthis command:

phpX.Y-sp -i | grep -i "OAuth"

You should see output like the following:

OAuthOAuth support=> enabled

Uninstalling the OAuth Extension

To uninstall this extension, as root run the commands:

sudo rm /etc/phpX.Y-sp/conf.d/oauth.inisudo peclX.Y-sp uninstall oauth

Next, restart PHP-FPM with the command:

sudo service phpX.Y-fpm-sp restart

How to Install the PHP Phalcon Extension

In the examples shown, replace "X.Y" with your app's PHP version(for example, "7.0").

Phalcon is a PHP web frameworkimplemented as a C extension offering high performance and lower resourceconsumption.

To use the Phalcon framework, you must first install thePhalcon PHP extension for your version of PHP.

Phalcon currently supports PHP 5.4, 5.5, 5.6, 7.0, 7.1, and 7.2.

Phalcon does not yet support 7.3.

Important: Your server must have at least 2 GB of memory to build andinstall the Phalcon extension.Attempting to install Phalcon on low-memory systems may crash yourserver!

To install this extension, run the following on your server asroot:

sudo apt-get -y install gcc make autoconf libc-dev pkg-configgit clone --depth=1 git://github.com/phalcon/cphalcon.gitcd cphalcon/buildsudo PATH=/opt/sp/phpX.Y/bin:$PATH ./install

If the last command above fails and exits with the messagegcc: internal compiler error: Killed (program cc1), your server doesnot have enough memory to install Phalcon.

When the above commands complete successfully, create a configuration file forthe extension and restart PHP by running the following commands asroot:

sudo bash -c "echo extension=phalcon.so > /etc/phpX.Y-sp/conf.d/phalcon.ini"sudo service phpX.Y-fpm-sp restart

You can verify Phalcon is installed by running this command:

phpX.Y-sp -i | grep phalcon

If Phalcon is installed correctly, you will see the following:

/etc/php7.2-sp/conf.d/phalcon.ini,phalconphalcon=> enabledphalcon.db.escape_identifiers=> On=> Onphalcon.db.force_casting=> Off=> Offphalcon.orm.cast_on_hydrate=> Off=> Offphalcon.orm.column_renaming=> On=> Onphalcon.orm.disable_assign_setters=> Off=> Offphalcon.orm.enable_implicit_joins=> On=> Onphalcon.orm.enable_literals=> On=> Onphalcon.orm.events=> On=> Onphalcon.orm.exception_on_failed_save=> Off=> Offphalcon.orm.ignore_unknown_columns=> Off=> Offphalcon.orm.late_state_binding=> Off=> Offphalcon.orm.not_null_validations=> On=> Onphalcon.orm.update_snapshot_on_save=> On=> Onphalcon.orm.virtual_foreign_keys=> On=> On

Uninstalling the Phalcon Extension

To uninstall this extension, as root run the command:

sudo rm /etc/phpX.Y-sp/conf.d/phalcon.ini

Next, restart PHP-FPM with the command:

sudo service phpX.Y-fpm-sp restart

How to Install the PHP Redis Extension

To install a PECL extension for multiple PHP versions, repeat thePECL extension installation for each PHP version.
This PHP extension provides client access tothe Redis server.It is not Redis itself.Redis is a server that provides a key/value store.When you install the Redis PHP extension, it will allow PHP to communicatewith a Redis server.Read more about installing the Redisserver.

Installing the Redis Extension on PHP 7.X

In the examples shown, replace "7.X" with your app's PHP version(for example, "7.0").

To install the PHP Redis extension on PHP 7.0, 7.1, 7.2, or 7.3,SSH in to your server as root andrun the following commands:

sudo apt-get -y install gcc make autoconf libc-dev pkg-configsudo pecl7.X-sp install redis

When prompted with the following:

enable igbinary serializer support? [no] :enable lzf compression support? [no] :

press Enter to accept the default both times.

Once installed, create a configuration file for the extension and restartPHP by running the following commands as root:

sudo bash -c "echo extension=redis.so > /etc/php7.X-sp/conf.d/redis.ini"sudo service php7.X-fpm-sp restart

Installing the Redis Extension on PHP 5.X

The most recent version of the Redis extension can only be installed on PHP7.0 and above.If you need to use the Redis extension on PHP 5.4, 5.5, or 5.6, youmust run Version 2.2.8.

In the examples shown, replace "5.X" with your app's PHP version(for example, "5.4").

To install this extension, run the following commands as your server'sroot user:

sudo apt-get -y install gcc make autoconf libc-dev pkg-configsudo pecl5.X-sp install redis-2.2.8

Once installed, create a configuration file for the extension and restartPHP by running the following commands as root:

sudo bash -c "echo extension=redis.so > /etc/php5.X-sp/conf.d/redis.ini"sudo service php5.X-fpm-sp restart

Using the PHP Redis Extension

See thedocumentationfor the PHP Redis extension for usage information.

Uninstalling the Redis Extension

To uninstall this extension, as root run the commands:

sudo rm /etc/phpX.Y-sp/conf.d/redis.inisudo peclX.Y-sp uninstall redis

Next, restart PHP-FPM with the command:

sudo service phpX.Y-fpm-sp restart

How to Install the PHP SSH2 Extension

In the examples shown, replace "X.Y" with your app's PHP version(for example, "5.4" or "7.1").To install a PECL extension for multiple PHP versions, repeat thePECL extension installation for each PHP version.

The SSH2 extensionprovides functions for accessing remote machines using the secure SSH andSFTP protocols.

Installing the SSH2 Extension on PHP 7.3

This extension does not yet support PHP 7.3.

Installing the SSH2 Extension on PHP 7.0, 7.1, or 7.2

Note: The SSH2 extension's support for PHP 7 is currently in alpha.

To install this extension on PHP 7.0, 7.1, or 7.2,SSH in as root and run thefollowing commands on your server:

sudo apt-get -y install gcc make autoconf libc-dev pkg-configsudo apt-get -y install libssh2-1-devsudo pecl7.X-sp install ssh2-alpha

Once installed, create a configuration file for the extension and restart PHP.

sudo bash -c "echo extension=ssh2.so > /etc/php7.X-sp/conf.d/ssh2.ini"sudo service php7.X-fpm-sp restart

Installing the SSH2 Extension on PHP 5

To install this extension on PHP 5.4, 5.5, or 5.6,SSH in as root and run thefollowing on your server:

sudo apt-get install gcc make autoconf libc-dev pkg-configsudo apt-get install libssh2-1-devsudo pecl5.X-sp install ssh2

Once installed, create a configuration file for the extension and restart PHP.

sudo bash -c "echo extension=ssh2.so > /etc/php5.X-sp/conf.d/ssh2.ini"sudo service php5.X-fpm-sp restart

Verifying the Installation

You can verify the SSH2 extension is installed with the command:

phpX.Y-sp -i | grep ssh2

If SSH2 is installed correctly, you will see the following:

/etc/phpX.Y-sp/conf.d/ssh2.ini,Registered PHP Streams=> https, ftps, compress.zlib, compress.bzip2, php,file, glob, data, http, ftp, zip, phar, ssh2.shell, ssh2.exec,ssh2.tunnel, ssh2.scp, ssh2.sftpssh2SSH2 support=> enabledlibssh2 version=> 1.4.3banner=> SSH-2.0-libssh2_1.4.3

Uninstalling the SSH2 Extension

To uninstall this extension, as root run the commands:

sudo rm /etc/phpX.Y-sp/conf.d/ssh2.inisudo peclX.Y-sp uninstall ssh2

Next, restart PHP-FPM with the command:

sudo service phpX.Y-fpm-sp restart

How to Install the PHP YAML Extension

To install a PECL extension for multiple PHP versions, repeat thePECL extension installation for each PHP version.

The PHP YAML extensionprovides PHP functions for parsing and serializing files and textcontaining YAML markup.

Installing the YAML Extension on PHP 7.3

This extension does not yet support PHP 7.3.

Installing the YAML Extension on PHP 7.0, 7.1, and 7.2

In the examples shown, replace "7.X" with your app's PHP version(for example, "7.0").

To install the PHP YAML extension on PHP 7.0, PHP 7.1, or PHP 7.2,SSH in to your server as root andfirst run these commands:

sudo apt-get -y install gcc make autoconf libc-dev pkg-configsudo apt-get -y install libyaml-dev

Next, run the following command:

sudo pecl7.X-sp install yaml

When you receive this prompt:

Please provide the prefix of libyaml installation [autodetect] :

press Enter without entering a prefix.This allows the library's location to be autodetected.

Once installed, create a configuration file for the extension and restartPHP by running the following command as root:

sudo bash -c "echo extension=yaml.so > /etc/php7.X-sp/conf.d/yaml.ini"sudo service php7.X-fpm-sp restart

Installing the YAML Extension on PHP 5.X

In the examples shown, replace "5.X" with your app's PHP version(for example, "5.6").

To install this extension on PHP 5.4, 5.5, or 5.6, first run the followingcommands as your server's root user:

sudo apt-get install gcc make autoconf libc-dev pkg-configsudo apt-get install libyaml-dev

Next, run the following command:

sudo pecl5.X-sp install yaml-1.3.0

When you receive this prompt:

Please provide the prefix of libyaml installation [autodetect] :

press Enter without entering a prefix.This allows the library's location to be autodetected.

Once installed, create a configuration file for the extension and restartPHP by running the following command as root:

sudo bash -c "echo extension=yaml.so > /etc/php5.X-sp/conf.d/yaml.ini"sudo service php5.X-fpm-sp restart

Verifying the PHP YAML Extension Is Installed

You can verify the YAML extension is installed by running this command,where X.Y is your app's PHP version:

phpX.Y-sp -i | grep yaml

You should see output similar to the following:

/etc/php7.0-sp/conf.d/yaml.ini,yamlLibYAML Support=> enabledLibYAML Version=> 0.1.4yaml.decode_binary=> 0=> 0yaml.decode_php=> 0=> 0yaml.decode_timestamp=> 0=> 0yaml.output_canonical=> 0=> 0yaml.output_indent=> 2=> 2yaml.output_width=> 80=> 80

Uninstalling the YAML Extension

To uninstall this extension, as root run the commands:

sudo rm /etc/phpX.Y-sp/conf.d/yaml.inisudo peclX.Y-sp uninstall yaml

Next, restart PHP-FPM with the command:

sudo service phpX.Y-fpm-sp restart

The most extended guide to PHP extensions

We hope you can work with These php extensions tutorials. Find out more about the best way to run PHP on cloud servers.