Installing from packages on GNU/Linux distributions that use DNF
While PHP can be installed from source, it is also available through packages on systems that use DNF, such as Red Hat Enterprise Linux, OpenSUSE, Fedora, CentOS, Rocky Linux, and Oracle Enterprise Linux.
While PHP can be installed from source, it is also available through packages on systems that use DNF, such as Red Hat Enterprise Linux, OpenSUSE, Fedora, CentOS, Rocky Linux, and Oracle Enterprise Linux.
Third-party-support
The packages can be installed using the dnf command.
Installing packages
First, note that other related packages may be desired like php-pear for PEAR, or php-mysqlnd for the MySQL extension.
Second, before installing a package, it's wise to ensure the package list is up to date. Typically, this is done by running the command dnf update.
DNF Install Example
# dnf install php php-common php-fpmDNF will automatically install the configuration for PHP for the web server, but it may need to be restarted in order for the changes to take effect. For example:
Restarting Apache httpd once PHP is installed
# sudo systemctl restart httpdBetter control of configuration
In the last section, PHP was installed with only core modules. It's very likely that additional modules will be desired, such as
These may also be installed via the dnf command.
Methods for listing additional PHP packages
# dnf search phpThe list of packages will include a large number of packages that includes basic PHP components, such as php-cli, php-fpm, and php-devel, as well as many PHP extensions. When extensions are installed, additional packages will be automatically installed as necessary to satisfy the dependencies of those packages.
Install PHP with MySQL, GD
# dnf install php-mysqlnd php-gdDNF will automatically add the appropriate lines to the different Ini related files like /etc/php.ini, /etc/php.d/*.ini, etc. and depending on the extension will add entries similar to extension=foo.so. However, restarting the web server and PHP-FPM is required before these changes take effect.