How to Install PHP 8.1 on Fedora 36 / Fedora 35 / 34 | Holhol24
PHP is an open-source, general-purpose scripting language mainly used in web development but has also been used as a general-purpose programming language.
In this post, we will see how to install PHP 8.1 on Fedora 36 / Fedora 35 / 34.
Add PHP Repository
Fedora 35 and Fedora 34 come with PHP v8.0 and PHP v7.4, respectively. To install PHP 8.1 on Fedora 35 / 34, you need to set up the REMI repository that offers different versions of PHP packages for the Fedora operating system.
To install PHP v8.1 on Fedora 36, you do not need to set up the REMI repository.
# Fedora 36 Packages available in Fedora repository # For PHP 8.1 on Fedora 35 sudo dnf install -y http://rpms.remirepo.net/fedora/remi-release-35.rpm # For PHP 8.0/8.1 Fedora 34 sudo dnf install -y http://rpms.remirepo.net/fedora/remi-release-34.rpm
Install PHP on Fedora 36/35/34
Now, install PHP v8.0/8.1 with the dnf
command.
# PHP 8.1 on Fedora 36 sudo dnf install -y php php-common php-cli # PHP 8.1 on Fedora 35 sudo dnf module enable -y php:remi-8.1 sudo dnf install -y php php-common php-cli # PHP 8.0 on Fedora 35 sudo dnf install -y php php-common php-cli # PHP 8.1 on Fedora 34 sudo dnf module enable -y php:remi-8.1 sudo dnf install -y php php-common php-cli # PHP 8.0 on Fedora 34 sudo dnf module enable -y php:remi-8.0 sudo dnf install -y php php-common php-cli
Check PHP Version
After installing PHP, use the below command to check its version.
php -v
Output:
PHP 8.1.6 (cli) (built: May 11 2022 01:14:18) (NTS gcc x86_64) Copyright (c) The PHP Group Zend Engine v4.1.6, Copyright (c) Zend Technologies with Zend OPcache v8.1.6, Copyright (c), by Zend Technologies
Install PHP Extensions on Fedora 36
PHP extensions allow developers to extend the capabilities of the PHP language. At their simplest, extensions can provide extra functionality that is not natively found in PHP (such as multi-threading).
For example, installing a PHP MySQL extension will support your code to connect with the MySQL database.
PHP extension packages are typically named php
To install MySQL support for PHP v8.0, you can install the php8.0-mysql
package.
sudo dnf install -y php-mysqlnd
Once you have installed a required extension, use the below command to verify it.
php -m | grep -i mysql
Output:
mysql mysqli mysqlnd pdo_mysql
Conclusion
That’s All. I hope you have learned how to install PHP 8.1 on Fedora 36 / Fedora 35 / 34.