1. Sometimes your web application requires a custom PHP extension that isn’t enabled by default in your virtual hosting environment. Fortunately, most hosting providers allow you to add or enable extensions manually.

    Steps to Add a PHP Extension

    1. Check Hosting Support
      Log into your hosting control panel (e.g., cPanel, DirectAdmin, Plesk) and look for Select PHP Version or PHP Extensions. Many providers let you enable extensions with a single click.

    2. Upload Custom Extension
      If the needed extension is not available, you can:

      • Download the extension .so (Linux) or .dll (Windows) file compatible with your PHP version.

      • Upload it to a directory on your hosting account (commonly /php/ext/).

    3. Edit php.ini or .user.ini
      Add a line pointing to the extension file:

      extension=/home/username/php/ext/extension_name.so

      For local configs, use .user.ini in your site’s root directory.

    4. Restart or Reload PHP
      On shared hosting with LiteSpeed or Apache + PHP-FPM, simply wait a few minutes or restart via the panel.

    5. Verify Installation
      Create a phpinfo.php file with:

      <?php phpinfo(); ?>

      Open it in your browser and confirm that the extension is listed.

    Conclusion

    Adding your own PHP extension in virtual hosting usually involves enabling it through the control panel or manually configuring php.ini. Always ensure compatibility with your hosting’s PHP version to avoid errors.