How to Install PHP on Fedora 44

Last updated Friday, May 15, 2026 2:53 pm Joshua James 8 min read

Fedora’s PHP packages track modern framework requirements without adding a third-party repository, which makes the official Fedora repository path through DNF the cleanest default for WordPress, Laravel, Symfony, CLI scripts, and local development. To install PHP on Fedora, use the package set that matches your web server, then verify the PHP branch, web-server integration path, and extension modules before deploying an application.

Fedora 44 currently ships PHP 8.5, while Fedora 43’s default PHP version is PHP 8.4. Both branches are listed on the upstream PHP supported versions page, but your exact patch release will change as Fedora publishes updates.

Install PHP on Fedora

The official Fedora repositories are the primary path for most systems. Use Remi only when an application specifically requires a different PHP branch or parallel PHP stacks; the default Fedora workflow does not use Remi module commands such as dnf module enable php:remi-8.3. For that separate repository path, use the dedicated guide to install the Remi RPM repository on Fedora.

Check Fedora’s Default PHP Version

Fedora can update PHP within a release, so check the repository candidate before you tie an application to a specific branch:

dnf info php

Relevant Fedora 44 output currently includes:

Name           : php
Version        : 8.5.6
Release        : 1.fc44
Repository     : updates

On Fedora 43, the same package query currently reports PHP 8.4 packages from the updates repository. If your framework needs a branch older or newer than Fedora provides, choose that branch deliberately instead of replacing the distro-owned PHP packages blindly.

Update Fedora Before Installing PHP

Refresh package metadata and apply pending updates before installing PHP so PHP, Apache or Nginx, OpenSSL, and extension libraries stay in sync:

sudo dnf upgrade --refresh

The --refresh option forces DNF to download fresh repository metadata instead of using an older local cache.

Choose Fedora PHP Packages

Pick one base package set. Apache and Nginx both use PHP-FPM on Fedora, but the web server package and configuration path differ.

Use CasePackagesWhat It ProvidesBest Fit
Apache websiteshttpd, php, php-cli, php-fpmApache plus Fedora’s packaged PHP-FPM proxy configurationLAMP stacks, WordPress, and existing Apache hosts
Nginx websitesnginx, php-fpm, php-cliNginx plus the PHP-FPM service and Unix socketLEMP stacks, reverse proxies, and separate FastCGI tuning
CLI scripts onlyphp-cliThe php command without a web server or PHP-FPM poolComposer scripts, cron jobs, and local command-line tools

If Apache or Nginx is already installed, DNF will keep the existing package and add only the missing PHP components. For new web servers, install the matching server package in the same transaction so service management and PHP testing are easier to follow.

Install PHP for Apache on Fedora

Install Apache, PHP-FPM, and the PHP command-line tools for a standard Apache PHP stack:

sudo dnf install httpd php php-cli php-fpm

The php-fpm package owns Fedora’s Apache PHP configuration at /etc/httpd/conf.d/php.conf. The php metapackage alone does not install Apache, so include httpd when you are building a new Apache host. For a broader Apache setup, virtual host, and firewall workflow, use the full guide to install Apache HTTPD on Fedora.

Install PHP-FPM for Nginx on Fedora

Install Nginx, PHP-FPM, and the PHP CLI for an Nginx-based stack:

sudo dnf install nginx php-fpm php-cli

Fedora’s stock PHP-FPM pool listens on /run/php-fpm/www.sock. The packaged pool keeps user = apache for compatibility, but it grants socket access to both Apache and Nginx through listen.acl_users = apache,nginx, so changing the pool user is not required for the default Nginx handoff.

Nginx still needs a server block that passes PHP requests to that socket. For broader Nginx service, firewall, and site setup, use the full guide to install Nginx on Fedora. For the PHP handoff itself, use the configuration guide for Nginx with PHP-FPM on Fedora.

Install PHP CLI Only on Fedora

For command-line scripts without a local web server, install only the PHP CLI package:

sudo dnf install php-cli

This is enough for simple PHP scripts, one-off checks, and tools that only need the php executable.

Verify PHP on Fedora

Confirm the PHP CLI is available and report the active major/minor branch:

php -r 'echo "PHP " . PHP_MAJOR_VERSION . "." . PHP_MINOR_VERSION . PHP_EOL;'

Fedora 44 currently returns:

PHP 8.5

Fedora 43 output starts with PHP 8.4 instead. The patch number can change after routine Fedora updates.

Manage PHP-FPM for Web Servers on Fedora

Skip this section for CLI-only installs. If you installed the Apache or Nginx package set, start PHP-FPM now and enable it for future boots:

sudo systemctl enable --now php-fpm

Use narrow service checks instead of a full status screen for normal verification:

systemctl is-active php-fpm
systemctl is-enabled php-fpm

A working service returns:

active
enabled

For Apache installations, start Apache as well:

sudo systemctl enable --now httpd

For Nginx installations, start Nginx after you have added a valid server block:

sudo systemctl enable --now nginx

The packaged PHP-FPM service creates the Unix socket at /run/php-fpm/www.sock. Check the socket and ACL settings when you need to confirm web-server access:

grep -E '^(user|group|listen|listen\.acl_users)' /etc/php-fpm.d/www.conf

Relevant Fedora defaults look like this:

user = apache
group = apache
listen = /run/php-fpm/www.sock
listen.acl_users = apache,nginx

Install PHP Extensions on Fedora

Install only the extensions your application needs. The package names below cover common CMS, framework, database, image, and network-monitoring requirements:

For the common GD extension requirement, Fedora’s package name is php-gd. Installing the RPM places the module configuration under /etc/php.d/, so there is no separate enable command for the standard Fedora package.

sudo dnf install php-gd php-mysqlnd php-pgsql php-intl php-bcmath php-soap php-process php-ldap php-tidy php-snmp
PackagePurpose
php-gdImage resizing, thumbnails, captchas, and chart generation
php-mysqlndMySQL and MariaDB support through the native driver
php-pgsqlPostgreSQL support through pgsql and pdo_pgsql
php-intlLocale-aware formatting, collation, calendars, and transliteration
php-bcmathArbitrary precision math for finance, IDs, and large numeric strings
php-soapSOAP client and server support
php-processProcess control functions such as pcntl and posix
php-ldapLDAP directory lookups and authentication integrations
php-tidyHTML cleanup and repair through libtidy
php-snmpSNMP support for monitoring tools and network inventory

For web-server installs, restart PHP-FPM after installing extension packages so web requests load the new modules. Skip this restart for CLI-only systems; PHP loads the extension set on the next php command:

sudo systemctl restart php-fpm

Install PECL Extensions on Fedora

Some widely used extensions are packaged from PECL. Install these when your application uses APCu, Redis, Memcached, or ImageMagick integration:

sudo dnf install php-pecl-apcu php-pecl-redis6 php-pecl-memcached php-pecl-imagick
  • php-pecl-apcu adds user-cache support for data that should persist between requests.
  • php-pecl-redis6 adds the Redis client extension often used for session storage, queues, and object caching.
  • php-pecl-memcached adds Memcached client support for distributed caching.
  • php-pecl-imagick adds ImageMagick bindings for advanced image manipulation.

If an older application checklist asks for php-json, modern Fedora PHP already includes the standard JSON extension. Fedora does not provide a separate php-json package for that extension, so install application-specific JSON helpers only when a project explicitly names them.

For web-server installs, restart PHP-FPM before testing the loaded modules:

sudo systemctl restart php-fpm

Then verify the selected modules are loaded:

php -m | grep -iE '^(apcu|redis|memcached|imagick|gd|intl|mysqli|mysqlnd|pdo_mysql|pdo_pgsql|pgsql)$'

Relevant output includes:

apcu
gd
imagick
intl
memcached
mysqli
mysqlnd
pdo_mysql
pdo_pgsql
pgsql
redis

View All Loaded PHP Modules

List every compiled-in and dynamically loaded module when you need a complete inventory:

php -m

Use the focused grep check above for a quick extension audit, and use the full module list when troubleshooting application requirements.

Install PHP Development Tools on Fedora

Development systems often need headers, debugging tools, and coverage drivers. Install these packages only on workstations, staging servers, or controlled development hosts:

sudo dnf install php-devel php-pecl-xdebug3 php-pecl-pcov

php-devel provides headers and build helpers for compiling PECL extensions. php-pecl-xdebug3 supports step debugging, stack traces, and profiling, while php-pecl-pcov provides a lighter coverage driver for test suites.

Keep Xdebug and PCOV out of production PHP pools unless you have a specific diagnostic window. Debug and coverage extensions can slow requests and expose details that belong only in development logs.

Most PHP projects also need Composer for dependency management. Install it separately with the guide to install Composer on Fedora so the Composer update and removal path stays clear.

Test PHP with Apache or Nginx on Fedora

For Apache, create a temporary PHP file under the default document root and request it from localhost:

printf '%s\n' '<?php echo PHP_MAJOR_VERSION . "." . PHP_MINOR_VERSION; ?>' | sudo tee /var/www/html/info.php > /dev/null
curl -fsS http://127.0.0.1/info.php

A working Apache and PHP-FPM handoff prints the PHP version:

8.5

Delete the test file immediately after the check:

sudo rm -f /var/www/html/info.php

Do not leave phpinfo() or version test files in a public document root. PHP information pages expose loaded modules, paths, environment details, and configuration values that can help attackers profile the server.

For Nginx, test PHP only after you have a server block that sends .php requests to /run/php-fpm/www.sock. The Fedora Nginx PHP-FPM guide linked earlier includes the server block, socket check, and reload sequence.

Configure PHP on Fedora

Check the active PHP configuration paths before editing:

php --ini

Relevant output includes:

Configuration File (php.ini) Path: "/etc"
Loaded Configuration File:         "/etc/php.ini"
Scan for additional .ini files in: "/etc/php.d"

Edit /etc/php.ini for global PHP settings:

sudo nano /etc/php.ini
  • memory_limit controls the maximum memory available to one script.
  • upload_max_filesize controls the maximum size of one uploaded file.
  • post_max_size controls the total POST body size and should be larger than upload_max_filesize.
  • max_execution_time limits how long a script can run before PHP stops it.
  • date.timezone sets the default timezone for date and time functions.

Extension configuration files live under /etc/php.d/, such as 10-opcache.ini or module-specific files added by extension packages. For web-server installs, restart PHP-FPM after changing PHP-FPM or extension settings:

sudo systemctl restart php-fpm

Restart Apache or reload Nginx when the web-server configuration also changed:

sudo systemctl restart httpd
sudo systemctl reload nginx

Troubleshoot PHP on Fedora

PHP File Downloads Instead of Running

If the browser downloads a .php file or displays raw PHP source, the web server is not handing that request to PHP-FPM. Start with the PHP-FPM service:

systemctl is-active php-fpm

A stopped service returns:

inactive

Start PHP-FPM and retry the request:

sudo systemctl start php-fpm

For Apache, confirm Fedora’s PHP configuration file exists, then restart both services:

ls /etc/httpd/conf.d/php.conf
sudo systemctl restart php-fpm httpd

For Nginx, verify your server block includes a fastcgi_pass unix:/run/php-fpm/www.sock; handoff and passes nginx -t before reload.

PHP-FPM Returns 502 Bad Gateway

A 502 Bad Gateway usually means Nginx or Apache reached PHP-FPM incorrectly, or PHP-FPM is not listening where the web server expects it.

502 Bad Gateway

Check the service and socket:

systemctl is-active php-fpm
test -S /run/php-fpm/www.sock && echo "PHP-FPM socket exists"

A healthy service and socket return:

active
PHP-FPM socket exists

Confirm the packaged pool grants access to the web-server users:

grep -E '^(listen|listen\.acl_users)' /etc/php-fpm.d/www.conf
listen = /run/php-fpm/www.sock
listen.acl_users = apache,nginx

If the service was stopped or the socket was missing, restart PHP-FPM and the affected web server:

sudo systemctl restart php-fpm
sudo systemctl restart httpd
sudo systemctl reload nginx

PHP Extension Does Not Load

If an installed extension is missing from php -m, confirm the package is installed and the module has an .ini file:

rpm -q --qf '%{NAME}\n' php-gd
ls /etc/php.d/*gd.ini

Expected output for GD looks like this:

php-gd
/etc/php.d/20-gd.ini

Then check PHP startup warnings:

php -i 2>&1 | grep -iE 'warning|error|unable|failed'

No output from that filtered check is usually good; warnings point to a missing dependency, duplicate extension load, or extension built for a different PHP branch.

Update or Remove PHP on Fedora

Update PHP on Fedora

Fedora updates PHP, PHP-FPM, and extension packages through the normal system update flow. Use a full DNF upgrade so the runtime, extensions, and dependent libraries stay on compatible builds:

sudo dnf upgrade --refresh

Avoid upgrading only a metapackage such as php when your system has several PHP extensions installed. A full update is safer because it keeps the loaded extension ABI aligned with the PHP branch Fedora currently publishes.

Remove PHP from Fedora

If PHP was installed for a web server, stop PHP-FPM before removing the PHP package set:

sudo systemctl stop php-fpm

Remove the base PHP packages. DNF will show any installed PHP extensions that must be removed because they depend on php-common, so review the transaction before confirming:

sudo dnf remove php php-cli php-fpm php-common

Verify the base packages are no longer installed:

rpm -q php php-cli php-fpm php-common || true
package php is not installed
package php-cli is not installed
package php-fpm is not installed
package php-common is not installed

Remove Apache or Nginx only when you installed that web server solely for this PHP setup and no other site depends on it:

sudo dnf remove httpd
sudo dnf remove nginx

Modified RPM configuration files can be preserved with a .rpmsave suffix after package removal. Check /etc/php.ini.rpmsave, /etc/php.d/, and web-server configuration directories before deleting leftover files on a host that previously served PHP applications.

Conclusion

PHP is installed on Fedora with official Fedora packages through DNF, PHP-FPM where a web server needs it, and the extension set your application requires. Keep updates tied to Fedora’s normal upgrade flow, verify web-server handoffs with a temporary local test file, and remove only the PHP or web-server packages that no remaining site still uses.

Follow LinuxCapable

Want more LinuxCapable guides in Google?

Add LinuxCapable as a preferred source so Google can show more of our fresh Linux tutorials in Top Stories and From your sources when relevant.

Add LinuxCapable as a preferred source on Google
Search LinuxCapable

Need another guide?

Search LinuxCapable for package installs, commands, troubleshooting, and follow-up guides related to what you just read.

Found this guide useful?

Support LinuxCapable to keep tutorials free and up to date.

Buy me a coffeeBuy me a coffee
Before commenting, please review our Comments Policy.
Formatting tips for your comment

You can use basic HTML to format your comment. Useful tags currently allowed in published comments:

You type Result
<code>command</code> command
<strong>bold</strong> bold
<em>italic</em> italic
<blockquote>quote</blockquote> quote block

Got a Question or Feedback?

We read and reply to every comment - let us know how we can help or improve this guide.

Let us know you are human: