PHP (Hypertext Preprocessor) is a general-purpose scripting language that is best suited especially for web development.
Many popular content management systems and frameworks like WordPress, Laravel, Drupal, etc are written in PHP. It is used on various servers to run web applications build in PHP.
Today in this article I will discuss how to install PHP on Fedora Linux.
Prerequisites
To follow this guide you should have the following.
- A system running a recent version of Fedora
- User account access with superuser privileges.
How to install PHP on Fedora
On Fedora 36 PHP is available in the default repository of Fedora so you can directly install it by using the dnf package manager in your terminal.
But before you install a package on your system make sure installed packages are updated –
sudo dnf update -yNow use the following command to install PHP on Fedora 36 –
sudo dnf install php -yNote:- At the time of writing this article the PHP 8.1 is available in the default repository of Fedora.
For instilling PHP on other version of Fedora you need to add REMI’s repository to your system.
For PHP 8.1 on Fedora 35/34
Use the given command to add the repository to your Fedora 35 system.
sudo dnf install -y http://rpms.remirepo.net/fedora/remi-release-35.rpmUse the given command to add the REMI’s repository to a Fedora 34 system.
sudo dnf install -y http://rpms.remirepo.net/fedora/remi-release-34.rpmOnce the repositories gets added use the following command to install the PHP 8.1 on Fedora 35/34 –
sudo dnf module enable -y php:remi-8.1sudo dnf install -y php php-common php-cliCheck PHP version
You can check the version of installed PHP on your system by using –
php -v
How to install PHP extension in Fedora
Extensions in PHP are used to extend the functionality of the language.
The format of a PHP extension is php-<extension_name>.
For example to add MySQL capabilities to lanauge you can install the given extension –
sudo dnf install -y php-mysqlndphp-cli php-fpm php-mcrypt php-mbstring php-json are examples of PHP extensions.
How to remove PHP from Fedora
For any reason if you want to remove PHP from your Fedora system then use –
sudo dnf remove phpPress y and then enter if it asks for your confirmation.
Conclusion
You have successfully installed PHP on your Fedora system.
Now if you have a query then write us in the comments below.