‹ Articles

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

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.


Last updated: February 26, 2018

Still Have Questions?

Don't hesitate to contact us if you can't find the answers to your questions.