Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
VGSources
Blog

How to Install PHP Modules on a Linux VPS

A practical guide to installing and verifying PHP extensions on a Linux VPS, with APT and DNF commands, SAPI-specific configuration paths, restart steps and PECL/phpize fallbacks.
Length9 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Install PHP modules with your VPS distribution’s package manager, then restart the PHP runtime that actually serves your application. On Debian or Ubuntu, the usual path is sudo apt update followed by sudo apt install php-<module>. On Fedora, RHEL and other DNF-based systems, search with dnf search php and install the matching package. Finally, verify the module in the correct SAPI (CLI, Apache, CGI or PHP-FPM), because a command-line PHP installation and a web application can load different configuration files.

This guide covers package names, Apache/Nginx and PHP-FPM restarts, version-specific php.ini locations, explicit enablement, diagnosis of “undefined function” errors, and the PECL/phpize fallback for extensions that are not available as normal distribution packages.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What a PHP module is and why installation can appear to fail

A PHP module (also called an extension) adds functionality that is not part of the smallest PHP runtime. Database drivers, cURL networking, image processing, XML handling and many other features are delivered as loadable extensions. A package manager normally installs the compiled module, its dependencies and the configuration fragment that tells PHP to load it.

Installation has three separate parts:

  • Package selection: choose a package compatible with the PHP version installed on the VPS.
  • Configuration: ensure the SAPI used by the application reads an ini file that enables the extension.
  • Process reload: restart Apache, PHP-FPM or another serving process so it reads the new module.

The most common mistake is checking only the CLI binary with php -m while the website runs under a different PHP-FPM pool or Apache module. Always verify the runtime that serves the application.

#1 Best Overall
Sale
Gaoye Blue Light Blocking Glasses
  • BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
  • EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
  • COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
  • LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
  • WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.

Before you install: identify the distribution, PHP version and SAPI

Identify the Linux distribution

Use the operating system’s release information to determine whether the VPS uses Debian/Ubuntu’s APT tooling or a DNF-based system:

cat /etc/os-release

Debian and Ubuntu use apt. Fedora, Rocky Linux, AlmaLinux, RHEL and related systems commonly use dnf (older releases may expose a compatible yum command).

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Check the installed PHP version and command-line configuration

php -v
php --ini
php -m

php -v identifies the CLI version. php --ini prints the CLI configuration file and the additional ini directory it scans. php -m lists modules loaded by that CLI binary; it does not prove that Apache or PHP-FPM loads the same modules.

Determine the web SAPI

Common deployments are:

  • Apache with mod_php: Apache loads PHP directly through its PHP module.
  • Apache or Nginx with PHP-FPM: a separate PHP-FPM service executes PHP requests.
  • CGI: a CGI PHP binary handles requests.
  • CLI: command-line scripts, queue workers and cron jobs use the CLI binary.

For a web request, a temporary diagnostic script containing <?php phpinfo(); displays the web SAPI, loaded configuration file and loaded modules. Place it where the application can reach it, inspect it, and remove it immediately afterward because it reveals server configuration. An application-level diagnostic that calls php_sapi_name() and checks the required function or class is another option.

Install modules on Debian or Ubuntu with APT

Refresh package metadata

sudo apt update

Run this before searching or installing so APT has current repository metadata. If the command reports repository or signature errors, resolve those first; an extension package cannot be selected reliably from stale or broken metadata.

Search for the package name

apt search php-
apt-cache search php

Package names are not always identical to the PHP function or feature name. Search results also show which packages are available for the distribution release and, in some repositories, for a particular PHP version.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Install the extension

Install one or more packages in a single command when they are available in the repositories:

Rank #2
Windex Gaming Cleaning Wipes, Pre-Moistened Wipes to Instantly Clean all Gaming Gear and Electronics, Resealable Packaging for a Freshness Lock, 25 count (Pack of 1)
  • WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
  • AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
  • PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
  • ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
  • COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed
sudo apt install php-mysql php-curl

Typical Debian/Ubuntu package names include:

Purpose Common package Notes
MySQL and compatible database APIs php-mysql Provides the PHP MySQL drivers supplied by the distribution.
cURL networking php-curl Enables cURL functions and related support.
PostgreSQL database APIs php-pgsql Use when the application connects to PostgreSQL.
Command-line interpreter php-cli Required for PHP scripts run from a shell, cron or a queue worker.
CGI support php-cgi Used by CGI-based deployments.
Apache integration libapache2-mod-php Used when Apache runs PHP through mod_php.

Ubuntu’s documented Apache setup uses:

sudo apt install php libapache2-mod-php

The unversioned names usually select the distribution’s default PHP stream. If your application requires a specific PHP release, confirm that the package candidate matches it instead of assuming that every php-* package targets the same version.

Enable or disable a module explicitly

Debian-family systems provide helper commands for modules that have an enablement file:

sudo phpenmod extension_name
sudo phpdismod extension_name

Use the extension’s configuration name, not necessarily the full APT package name. If the package already installed an enabled fragment, these commands may not be necessary; they are useful when a module was disabled intentionally or when you need to make the state explicit.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Install modules on Fedora, RHEL and other DNF systems

Search the enabled repositories

sudo dnf search php

The result depends on the operating-system release, enabled repositories and PHP stream. Select a package that matches the PHP version used by the application rather than simply choosing the first similarly named result.

Install the required package

sudo dnf install php-mysqlnd php-gd

php-mysqlnd supplies the MySQL native driver package used by many DNF-based distributions, while php-gd supplies common image functions. Other extensions follow the same search-and-install pattern, but names can differ from Debian/Ubuntu names. Do not substitute php-mysql automatically on a DNF system without checking the package search results.

DNF installs the main configuration in locations such as /etc/php.ini and extension fragments under /etc/php.d/*.ini. The exact files present depend on the distribution and PHP stream.

Restart the runtime that serves the application

Installing a package does not reload a running PHP process. Restart the service associated with your deployment after changing modules or their ini files.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
LISEN Cell Phone Stand Phone Holder for Desk, Office Decor Gadgets for Men
  • Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
  • Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
  • Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
  • ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
  • Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)

Apache on Debian or Ubuntu

sudo systemctl restart apache2

Use this when Apache handles PHP through its module or when Apache is the process that must be reloaded for the deployment.

Apache on a DNF-based system

sudo systemctl restart httpd

The DNF documentation uses the httpd service name for Apache.

PHP-FPM behind Apache or Nginx

Restart the PHP-FPM service for the installed PHP version. Service names vary by distribution and version, so first inspect the available units if you are unsure:

systemctl list-units --type=service | grep -i fpm

Then restart the matching unit, for example:

sudo systemctl restart php-fpm

Some systems use a versioned name such as php8.2-fpm. Restarting Nginx alone does not reload PHP-FPM workers, and restarting PHP-FPM alone does not reload an independently cached web-server configuration; restart the process that owns the PHP runtime you changed.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Verify the module in the right SAPI

Verify CLI PHP

php -m | grep -i module_name
php --ini

Replace module_name with the module’s displayed name. The case shown by php -m may differ from the package name.

Verify Apache, CGI or PHP-FPM

Use phpinfo() or an application-level health check through the same URL, worker, queue process or cron context that failed. Confirm all three values:

  • The PHP version is the one for which you installed the package.
  • The “Loaded Configuration File” belongs to the expected SAPI.
  • The module appears in the loaded-modules list and its configuration is enabled.

On Debian-family systems, configuration commonly looks like:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Ledagic IC+RGBW USB Powered Led Light Bar with App & Remote Control, 2 Pack
  • Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
  • Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
  • 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
  • Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
  • USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC
/etc/php/M.N/cli/php.ini
/etc/php/M.N/$SAPI/conf.d/

Here M.N is the PHP major and minor version, and $SAPI can be cli, apache2, cgi or fpm. A module enabled for cli is not automatically enabled for fpm.

Which installation approach should you use?

Approach Best use SAPI and version considerations Maintenance and restart
Distribution package with APT Debian or Ubuntu when a suitable package exists. Choose a package compatible with the installed PHP stream; configuration is separated by version and SAPI. Dependencies and security updates come from the distribution. Restart Apache or PHP-FPM after installation.
Distribution package with DNF Fedora, RHEL-family and other DNF systems. Use the package returned by dnf search php for the enabled PHP stream. DNF manages dependencies and places fragments under /etc/php.d; restart the serving service.
PECL An extension is not available as a suitable repository package. Build against the PHP development environment that matches the target SAPI and PHP version. You must maintain the compiled extension and its compatibility. Add its ini directive and restart the runtime.
phpize/source build You have source code or a PECL package that must be compiled manually. The phpize binary and headers must correspond to the PHP installation that will load the module. Manual upgrades and security maintenance are your responsibility; configuration and a service restart are required.

Distribution packages are the default path because the repository handles dependency resolution and receives the operating system’s update stream. PECL or a source build is a fallback, not a reason to bypass a suitable maintained package.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Fallback: install an unavailable extension with PECL or phpize

Use this route only when the normal repository does not contain a compatible package or the available package does not meet the application’s requirements. You need a compiler toolchain and PHP development headers appropriate to the target PHP version; install those prerequisites through your distribution before building.

PECL workflow

PECL can download and compile extensions distributed through the PHP extension ecosystem. Follow the extension’s documented build options, then identify the resulting shared object (normally an .so file) and configure the target SAPI to load it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

phpize workflow

For source distributed with a PHP extension, the documented build sequence is:

phpize
./configure
make
sudo make install

phpize prepares the source tree for the PHP installation; ./configure checks available libraries and build options; make compiles the extension; and make install copies the module into PHP’s extension directory. A successful compilation alone does not load the module.

Add the extension directive and restart

Add the module to the ini file read by the target SAPI:

Best Value
Sale
HUANUO FlowLift™ Dual Monitor Stand, Fully Adjustable Gaming Monitor Desk Mount for 13–32″ Computer Screens, Full Motion VESA 75x75/100x100 with C-Clamp & Grommet Base, Each Arm Holds 4.4 to 19.8 lbs
  • Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
  • Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
  • Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
  • Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
  • Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.
extension=extname.so

On Debian-family systems, put the directive in the appropriate version/SAPI configuration tree. On DNF systems, an extension fragment under /etc/php.d/ is the usual pattern. Avoid adding the same directive repeatedly in multiple files because duplicate loading can produce startup warnings. Restart Apache or PHP-FPM, then verify through that SAPI.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Troubleshoot “undefined function” after installation

1. Confirm the package actually matches the missing feature

Compare the function or class required by the application with the module package you installed. For example, a database driver, cURL support and image support are separate capabilities. Search the package index again rather than assuming that a similarly named package provides the API you need.

2. Check for a PHP-version mismatch

Run php -v and compare it with the version shown by the web application’s phpinfo() page. A CLI binary can be PHP 8.x while the website is attached to a different PHP-FPM version. Install the module for the runtime that executes the request, or change the application’s configured PHP runtime deliberately.

3. Inspect the loaded ini files

Use php --ini for CLI and the “Loaded Configuration File” plus “Scan this dir for additional .ini files” values in phpinfo() for web requests. Verify that the extension’s ini fragment is in the directory actually scanned by that SAPI.

4. Restart the correct process

Restart Apache, httpd or the applicable PHP-FPM unit after installation or configuration changes. A browser test can continue to hit old workers until the serving process is restarted.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

5. Look for startup warnings and dependency errors

Run the relevant PHP binary from a shell and inspect its startup output. Messages such as “unable to load dynamic library” indicate a missing shared-library dependency, an incorrect extension path or a module compiled for another PHP build. Correct the package or build dependency rather than suppressing the warning.

6. Check permissions and service logs

If the CLI test succeeds but web requests fail, inspect the Apache or PHP-FPM service status and logs. The web worker may use a different user, chroot, pool configuration or environment. A module that loads in CLI is not proof that the web worker can access every library it needs.

Practical installation checklist

  1. Record the distribution and release with cat /etc/os-release.
  2. Record the PHP version with php -v, and identify the web version separately if the site uses Apache, Nginx or PHP-FPM.
  3. Identify the application’s SAPI: CLI, Apache, CGI or FPM.
  4. Refresh APT metadata or search the enabled DNF repositories.
  5. Install the package whose name and version match the required extension.
  6. Check whether Debian’s phpenmod is needed for explicit enablement.
  7. Inspect the SAPI-specific ini path before editing configuration manually.
  8. Restart the process that executes PHP requests.
  9. Verify with php -m for CLI and phpinfo() or an application check for web traffic.
  10. If no suitable package exists, use PECL or the phpize build sequence, add extension=extname.so, and repeat the restart and verification steps.

Key points to retain

  • Use the Linux distribution package manager whenever it provides a suitable PHP extension.
  • Package names differ between systems: Debian/Ubuntu examples include php-mysql, php-curl and php-pgsql; DNF examples include php-mysqlnd and php-gd.
  • CLI and web SAPIs can load different ini trees, so always test the runtime that runs the application.
  • Restart Apache, httpd, PHP-FPM or the relevant serving process after changing modules.
  • Reserve PECL and phpize for extensions that are not suitably packaged or maintained in the enabled repositories.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.