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.
Збірки від сторонніх розробників вважаються неофіційними і безпосередньо проектом PHP не підтримуються. Про знайдені вади, якщо вони не можуть бути відтворені на » офіційних збірках, необхідно повідомляти постачальників цих неофіційних збірок.
The packages can be installed using the dnf command.
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.
Приклад #1 DNF Install Example
# dnf install php php-common
DNF 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:
Приклад #2 Restarting Apache once PHP is installed
# sudo systemctl restart httpd
In the last section, PHP was installed with only core modules. It's very likely that additional modules will be desired, such as MySQL, cURL, GD, etc. These may also be installed via the dnf command.
Приклад #3 Methods for listing additional PHP packages
# dnf search php
The 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.
Приклад #4 Install PHP with MySQL, GD
# dnf install php-mysqlnd php-gd
DNF will automatically add the appropriate lines to the
different php.ini related files like
/etc/php/8.3/php.ini,
/etc/php/8.3/conf.d/*.ini, etc. and depending on
the extension will add entries similar to extension=foo.so
.
However, restarting the web server (like Apache) is required before these
changes take affect.