How to Install PHP 8.2 for Nginx on Fedora 40

To install PHP 8.2 for Nginx on Fedora 40, follow these steps:

Step 1 : Update your system:

Step 2 : Import the PHP Remi Repository:

Step 3 : Check available PHP modules:

Step 4 : Enable the PHP Remi Repository:

Step 5 : Install PHP core and PHP-FPM:

Step 6 : Install commonly used PHP extensions:

  • php-mysqlnd: Native driver for MySQL/MariaDB connectivity in PHP.
  • php-curl: Allows PHP to make HTTP requests to other servers.
  • php-gd: Graphics library for dynamic image processing in PHP.
  • php-mcrypt: Deprecated cryptography library for encryption/decryption.
  • php-json: Handles JSON data encoding/decoding in PHP.
  • php-pear: Installs the PEAR package manager for PHP.
  • php-common: Common files and functions shared among PHP extensions.
  • php-xml: Handles XML parsing, generation, and manipulation in PHP.
  • php-zip: Allows PHP to work with ZIP archives for compression/extraction.
  • php-devel: Development files for building PHP extensions from source.
  • php-xsl: Applies XSLT stylesheets to XML data for transformation.
  • php-soap: Supports creation and consumption of SOAP web services in PHP.

Step 7 : Open the file /etc/php-fpm.d/www.conf, replace the user and group from apache to nginx:

Step 8 : Restart PHP-FPM:

Step 9 : Create a configuration file for your domain (e.g., example.com)

- Add the following content:

Step 10 : Test your Nginx configuration:

Step 11 : Restart Nginx:

Step 12 : Test PHP by creating a phpinfo file:

Step 13 : Visit your domain to see the phpinfo result (e.g., http://example.com/info.php).

Congratulations! You have successfully installed PHP 8.2 for Nginx on Fedora 40.