How to Install PHP 8.0/8.1 on Fedora 35 / Fedora 34

0

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.0/8.1 on Fedora 35 / Fedora 34.

Add PHP 8.0/8.1 Repository on Fedora 35

By default, 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.0 on Fedora 35, you do not need to set up the REMI repository.
# For PHP 8.1 on Fedora 35

sudo dnf -y install http://rpms.remirepo.net/fedora/remi-release-35.rpm

# For PHP 8.0/8.1 Fedora 34

sudo dnf -y install http://rpms.remirepo.net/fedora/remi-release-34.rpm

Install PHP 8.0/8.1 on Fedora 35

Now, install PHP v8.0/8.1 with the dnf command.

# 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.0.9 (cli) (built: Jul 30 2021 13:09:45) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.9, Copyright (c) Zend Technologies
with Zend OPcache v8.0.9, Copyright (c), by Zend Technologies

Install PHP Extensions on Fedora 35

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<version>-<extn_name>.

To install MySQL support for PHP v8.0, you can install the php8.0-mysql package.

sudo dnf install -y php-mysql

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.0/8.1 on Fedora 35 / Fedora 34.

You might also like