Atlantic.Net Blog

How to Install PHP on Fedora

PHP, also called “PHP: Hypertext Preprocessor,” is a widely-used, open-source scripting language for managing dynamic content. It is a server-side scripting language that is embedded in HTML. Generally, PHP is used with Apache and Nginx web servers to build dynamic websites, static websites, and web applications. It is also a general-purpose language that you can use to make many projects, including Graphical User Interfaces.

This post will show you how to install PHP 5.6, 7.4, 8.0, and 8.1 on Fedora 34.

Install PHP 8.1

By default, PHP 8.1 is not included in the Fedora 34 default repo, so you will need to install the PHP Remi repository on your server. You can install it with the following command.

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

Next, enable the Remi repository with the following command.

dnf module install php:remi-8.1

Next, install PHP 8.1 with other extensions with the following command.

dnf install -y php php-common php-cli

After the installation, verify the PHP version using the following command.

php -v

You should get the following output.

PHP 8.1.9 (cli) (built: Aug  2 2022 13:02:24) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.1.9, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.9, Copyright (c), by Zend Technologies

Install PHP 8.0

First, reset the PHP default module with the following command.

dnf module reset php -y

Next, install the Remi module for PHP 8.0 with the following command.

dnf module install php:remi-8.0

Next, install PHP and other extensions using the following command.

dnf install -y php php-common php-cli

Once all the packages are installed, you can verify the PHP version with the following command.

php -v

You should see the following output.

PHP 8.0.22 (cli) (built: Aug  2 2022 08:01:15) ( NTS gcc x86_64 )
Copyright (c) The PHP Group
Zend Engine v4.0.22, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.22, Copyright (c), by Zend Technologies

Install PHP 7.4

First, reset the PHP default module with the following command.

dnf module reset php -y

Next, install the Remi module for PHP 7.4 with the following command.

dnf module install php:remi-7.4 -y

Next, install PHP with other extensions using the following command.

dnf install -y php php-common php-cli

Finally, verify the PHP version using the following command.

php -v

You should see the following output.

PHP 7.4.30 (cli) (built: Jun  7 2022 08:38:19) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.30, Copyright (c), by Zend Technologies

Install PHP 5.6

First, reset the PHP default module with the following command.

dnf module reset php -y

Next, install PHP 5.6 with the following command.

dnf --enablerepo=remi install php56

After the installation, you can verify the PHP installation using the following command.

php56 -v

You should see the following output.

PHP 5.6.40 (cli) (built: Jun  7 2022 00:00:00) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

Install PHP Extensions

You can also install some required PHP extensions with the following command.

dnf install -y php-mysqlnd php-gd php-curl php-json -y

You can verify the installed PHP extensions using the following command.

php -m | grep -i mysql

You should see the following output.

mysqli
mysqlnd
pdo_mysql

Conclusion

This tutorial showed you how to install PHP 5.6, 7.4, 8.0, and 8.1 on Fedora 34. You can now easily install any PHP version on your server as per your needs. Try to install PHP on dedicated server hosting from Atlantic.Net!

Get a $250 Credit and Access to Our Free Tier!

Free Tier includes:
G3.2GB Cloud VPS a Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year