Skip to main content Start of main content

How to install PHP on Rocky Linux 10

Installing PHP on Rocky Linux 10 (released in June 2025) is more straightforward than previous versions because PHP 8.3 is included as the default version in the standard appstream repository.

There are two ways to install it: using the default system repositories (recommended for stability) or using the Remi repository (for the absolute latest versions like PHP 8.4).

How to install PHP on Rocky Linux 10

Option 1: Install Default PHP (PHP 8.3)

Rocky Linux 10 provides PHP 8.3 out of the box. This is the simplest method and is recommended for most users.


1. Prerequisites

Before you begin, Update your system:

  • You have sudo or root access
  • Your system is up to date
  • You have an active internet connection

Update your system:

$ sudo dnf update -y

2. Install PHP and common extensions:

PHP is available in the default Rocky Linux repositories. Install it using the dnf package manager:

$ sudo dnf install php php-cli php-fpm php-curl php-mysqlnd php-gd php-opcache php-zip php-intl php-common php-mbstring php-xml -y

After installation, PHP files are located in the following directories:

  • Primary location: /usr/bin/php
  • Alternative: /usr/local/bin/php

3. Start and enable PHP-FPM:

If you are using a web server like Nginx or Apache, you need the FastCGI Process Manager (FPM).

    $ sudo systemctl enable --now php-fpm 

Verify the installation:

$ php -v

4. Install Latest PHP (PHP 8.4+) via Remi

If you need a newer version than what is in the official repositories, you can use the Remi repository:

$ sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-10.noarch.rpm -y
$ sudo dnf install https://rpms.remirepo.net/enterprise/remi-release-10.rpm -y

Reset the default PHP module:

$ sudo dnf module reset php -y

Enable the desired PHP version (e.g., 8.4):

$ sudo dnf module enable php:remi-8.4 -y

Important Post-Installation Steps active (running).


5. Configure the Firewall

Test PHP Processing

To verify that your web server is correctly processing PHP, create a test file in your web root (usually /var/www/html/):

$ echo '?php phpinfo(); ?>' | sudo tee /var/www/html/info.php

Visit http://your-server-ip/info.php in your browser. You should see a detailed page about your PHP environment.

6. Common Extensions Table

To verify that your web server is correctly processing PHP, create a test file in your web root (usually /var/www/html/):

Depending on your application (WordPress, Laravel, etc.), you might need specific modules:

Module
Purpose
php-mysqlnd
Database connection for MySQL/MariaDB
php-gd
Image manipulation
php-mbstring
Support for multi-byte characters (Unicode)
php-xml
XML and DOM manipulation
php-bcmath
Precise mathematical calculations

Download Absolute Linux

RELEASE DATE: Tuesday, April 23, 2024

For Intel and AMD x86_64 systems

Absolute Linux Live ISOiso4.3 GiB

No files available for this version.

We take security seriously

Once you have downloaded an image, be sure to verify it for both security and integrity.

By calculating the image’s checksum on your own computer and comparing it to the original checksum, you can verify the image has not been tampered with or corrupted. Images are also gpg signed with Fedora keys to demonstrate their integrity.

  • Click the verify button to download the checksum file for your downloaded image.

  • Import Linuxrpms's GPG key(s)

                    curl -O https://linuxrpms.com/linuxrpms-gpg.pub
                  

    You can verify the details of the GPG key(s) here.

  • Verify the checksum file is valid

                    gpgv --keyring ./linuxrpms-gpg.pub absolutelinux-*-CHECKSUM
                  
  • Verify the checksum matches

                    sha256sum -c absolutelinux-*-CHECKSUM
                  

If the output states that the file is valid, then it's ready to use!

By clicking on and downloading Rocky Linux, you agree to comply with the US Export Control Policy.

Linuxrpms Logo