How To Install PHP 8.1 on Fedora 35/34/33/32/31/30
source link: https://computingforgeeks.com/how-to-install-php-on-fedora-linux-system/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Are you looking for an easy way to install PHP 8.1 on Fedora 35/34/33/32/31/30?. PHP 8.1 packages for Fedora operating system are available in the Remi repository. PHP is a general-purpose scripting language suit for creation of dynamic web pages and powerful web applications. PHP was originally created by Rasmus Lerdorf in 1994.
In this tutorial we shall discuss on the steps required to install and run PHP 8.1 on Fedora 35/34/33/32/31/30 Linux. This can be on a cloud instance, on-prem server installation of Fedora, or on your Fedora workstation system.
New Features in PHP 8.1
Below are some new features in PHP 8.1 release. More details about each feature is available in the official PHP website.
- Readonly properties – Class properties can be marked as readonly hence can only be written once
- Support for DNS-over-HTTPS (DoH)
- AVIF Image Format support – The PHP 8.1’s image processing and GD extension adds support for AVIF images.
- Never Return Type – A new return type hint called never is added in PHP 8.1
- Added support for Fibers – The low level mechanism to manage parallelism
- PHP 8.1 adds array_is_list as a built-in function
- File Uploads with CURLStringFile – In PHP 8.1, PHP Curl extension now supports HTTP(S) requests with file uploads
- Enums – They are now added in PHP 8.1
- New fdatasync() and fsync() Functions
- New Sodium XChaCha20 functions
- Addition of pure intersection types feature
- Explicit Octal Numeral Notation
- Define final Class Constants
- MurmurHash3 hash algorithm support
- Intersection Types
- xxHash hash algorithms support
- For detailed information read through the official PHP 8.1 notes
Install PHP 8.1 on Fedora 35/34/33/32/31/30
For normal PHP requirements, you can go with the latest version available on the default Fedora RPM repositories. For any version of PHP not in the default repos, you’ll be required to add third party repository such as REMI or build from source.
Step 1: Enable Remi repository on Fedora 35/34/33/32/31/30
Perform an update on your Fedora system
sudo dnf -y update
Then proceed to enable Remi repository on Fedora 35/34/33/32/31/30:
Fedora 35:
sudo dnf -y install http://rpms.remirepo.net/fedora/remi-release-35.rpm
Fedora 34:
sudo dnf -y install http://rpms.remirepo.net/fedora/remi-release-34.rpm
Fedora 33:
sudo dnf -y install http://rpms.remirepo.net/fedora/remi-release-33.rpm
Fedora 32:
sudo dnf -y install http://rpms.remirepo.net/fedora/remi-release-32.rpm
Fedora 31:
sudo dnf -y install http://rpms.remirepo.net/fedora/remi-release-31.rpm
Fedora 30:
sudo dnf -y install http://rpms.remirepo.net/fedora/remi-release-30.rpm
Step 2: Install PHP 8.1 on Fedora 35/34/33/32/31/30
After addition of REMI repository, disable default AppStream PHP module.
sudo dnf -y module reset php
Enable php:remi-8.1
module
sudo dnf -y install dnf-plugins-core
sudo dnf config-manager --set-enabled remi
sudo dnf -y module install php:remi-8.1
Check installed version of PHP on your Fedora Linux:
$ php --version
PHP 8.1.0 (cli) (built: Nov 23 2021 18:56:11) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.1.0, Copyright (c) Zend Technologies
Installing multiple versions of PHP
If you’re interested in having multiple versions of PHP on your Fedora system, then install from php81 collection which is available in the remi-safe repository and can be installed with the command:
sudo dnf install php81
Additional PHP extensions can then be installed using the command:
sudo dnf install php81-php-xxx
To check the version of PHP 8.1 installed using this method, run:
$ php81 --version
PHP 8.1.0 (cli) (built: Nov 23 2021 18:56:11) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.1.0, Copyright (c) Zend Technologies
with Zend OPcache v8.1.0, Copyright (c), by Zend Technologies
Step 3:Install PHP 8.1 extensions on Fedora 35/34/33/32/31/30
Install PHP extensions using the name format php-<extension>.
sudo dnf install php-<extension>
Here is an example to install mostly used extensions of PHP:
sudo dnf install php-{cli,fpm,mysqlnd,zip,devel,gd,mcrypt,mbstring,curl,xml,pear,bcmath,json,opcache}
Step 4: Use PHP-FPM on Nginx / Apache httpd
The default PHP configuration file is /etc/php.ini.
sudo cat /etc/php.ini
For Nginx web server, use PHP-FPM (FastCGI Process Manager) configuration file to set CGI settings:
sudo vim /etc/php-fpm.d/www.conf
Once your PHP and PHP-FPM settings are modified, nginx and httpd web server services can be restarted.
# Nginx
sudo systemctl enable --now php-fpmsudo systemctl restart nginx
# Apache
sudo systemctl enable --now php-fpmsudo systemctl restart httpd
You should now have PHP 8.1 installed on Fedora 35/34/33/32/31/30. Enjoy PHP Development and have an amazing Code time.
Installation of PHP 8.1 on other systems:
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK