How to Install PHP 8.3 in RHEL 9

PHP is a popular programming language used for building dynamic web applications. With the release of PHP 8.3, developers gain access to new features and improvements.

For this guide, we will be operating the system as root, if that is not the case for you, make use of the sudo command to acquire root privileges.

Step 1: Update System Packages

To install the latest version of PHP, first, you need to update your system’s package repository and install newer available packages using the dnf command.

sudo dnf update
Update System Packages
Update System Packages

Step 2: Enable EPEL Repository in RHEL

Next, install the epel-release package, which provides additional packages for the RHEL system.

sudo subscription-manager repos --enable codeready-builder-for-rhel-9-$(arch)-rpms
sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
Enable EPEL Repository in RHEL
Enable EPEL Repository in RHEL

Step 3: Enable Remi Repository in RHEL

Next, you need to enable the Remi repository which offers the latest PHP versions for RHEL systems.

sudo dnf install https://rpms.remirepo.net/enterprise/remi-release-9.rpm
Enable Remi Repository in RHEL
Enable Remi Repository in RHEL

Step 4: Install PHP 8.3 in RHEL

Now, you can install PHP 8.3 along with the necessary extensions.

sudo dnf module install php:remi-8.3
Install PHP in RHEL
Install PHP in RHEL

Once installed, you can verify the PHP installation.

php -v
Verify PHP in RHEL
Verify PHP in RHEL

Step 5: Install Additional PHP Extensions (Optional)

Depending on your project requirements, you may need to install additional PHP extensions.

sudo dnf search php-*
Search for PHP Extensions
Search for PHP Extensions

Next, install the desired extensions using:

sudo dnf install php-gd php-xml
Install PHP Extensions in RHEL
Install PHP Extensions in RHEL

If you’re using Apache or Nginx as your web server, restart it to apply the changes.

sudo systemctl restart httpd
Or
sudo systemctl restart nginx

Lastly, below is a list of useful PHP articles that you can read for additional information:

You have successfully installed PHP 8.3 on your RHEL 9 system. You can now start developing or hosting web applications using the latest PHP version, taking advantage of its new features and enhancements.

Hey TecMint readers,

Exciting news! Every month, our top blog commenters will have the chance to win fantastic rewards, like free Linux eBooks such as RHCE, RHCSA, LFCS, Learn Linux, and Awk, each worth $20!

Learn more about the contest and stand a chance to win by sharing your thoughts below!

Aaron Kili
Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

27 Comments

Leave a Reply
  1. I have a problem in the third step when I entered the code of PHP 7.3 then it shown the message command not found.

    Reply
  2. Hey,

    Maybe a stupid question. But how can we start and restart PHP without rebooting the server?

    PHP 7.4.4 (cli) (built: Mar 17 2020 10:40:21) ( NTS )
    Copyright (c) The PHP Group
    Zend Engine v3.4.0, Copyright (c) Zend Technologies
    

    When we do [systemctl restart php74] results in Failed to restart php74.service: Unit not found.

    When we do [systemctl | grep php] not a single result is returned. Is php74.service not running? Or is it part of something else cause we installed it with the yum manager or something?

    Regards Jerome.

    Reply
    • @Jerome,

      PHP is a just programming language that doesn’t have a service to start, you just need to restart the Apache or Nginx webserver to reflect changes you made to any configuration files of PHP.

      # systemctl restart httpd
      OR
      # systemctl restart nginx
      
      Reply
  3. When running command : yum-config-manager --enable remi-php70

    this results, is this okay?

    ================================= repo: remi-php72 ==================================
    [remi-php72]
    async = True
    bandwidth = 0
    base_persistdir = /var/lib/yum/repos/x86_64/latest
    baseurl = 
    cache = 0
    cachedir = /var/cache/yum/x86_64/latest/remi-php72
    check_config_file_age = True
    compare_providers_priority = 80
    cost = 1000
    deltarpm_metadata_percentage = 100
    deltarpm_percentage = 
    enabled = True
    enablegroups = True
    exclude = 
    failovermethod = priority
    ftp_disable_epsv = False
    gpgcadir = /var/lib/yum/repos/x86_64/latest/remi-php72/gpgcadir
    gpgcakey = 
    gpgcheck = True
    gpgdir = /var/lib/yum/repos/x86_64/latest/remi-php72/gpgdir
    gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
    hdrdir = /var/cache/yum/x86_64/latest/remi-php72/headers
    http_caching = all
    includepkgs = 
    ip_resolve = 
    keepalive = True
    keepcache = False
    mddownloadpolicy = sqlite
    mdpolicy = group:small
    mediaid = 
    metadata_expire = 21600
    metadata_expire_filter = read-only:present
    metalink = 
    minrate = 0
    mirrorlist = http://cdn.remirepo.net/enterprise/7/php72/mirror
    mirrorlist_expire = 86400
    name = Remi's PHP 7.2 RPM repository for Enterprise Linux 7 - x86_64
    old_base_cache_dir = 
    password = 
    persistdir = /var/lib/yum/repos/x86_64/latest/remi-php72
    pkgdir = /var/cache/yum/x86_64/latest/remi-php72/packages
    priority = 99
    proxy = False
    proxy_dict = 
    proxy_password = 
    proxy_username = 
    repo_gpgcheck = False
    report_instanceid = False
    retries = 3
    skip_if_unavailable = False
    ssl_check_cert_permissions = True
    sslcacert = 
    sslclientcert = 
    sslclientkey = 
    sslverify = True
    throttle = 0
    timeout = 5.0
    ui_id = remi-php72
    ui_repoid_vars = releasever,
       basearch
    username =
    
    Reply
  4. Hey, how to Remove the PHP installed by this tutorial, I used this tutorial to install PHP 7.2 and now I wanted to remove it, It Not showing in Package On in ->

    $ which php
    /usr/local/bin/php
    
    $ whereis php
    php: /usr/bin/php /usr/lib/php /usr/local/bin/php 
    

    What is the Solution ?

    Reply
  5. Hi,
    Thank you so much for your great article.

    I’m installing two PHP version 5.6 and 7, but when I enter php -v, it seems it only show 5.6. How can I use both of them?

    Reply
    • @Vince

      You can only view one PHP version on the command line, which is the default version. But you can run different sites using different PHP versions, which requires some configurations.

      Reply
  6. I have a question, I did this on my VPS to work with php 7.1 for laravel. After everything went good, all my wordpress websites got an 502 gateway error. I immediately got the backup restored and got my sites back, but now the PHP version is back to the old 5.6.3 which is to low for my laravel thing.

    Is there any solution?

    Reply
    • @sonia

      You can run following command to remove PHP completely.

      $ sudo yum -y remove php*
      OR
      # yum -y remove php*
      

      Then install the PHP version you want to use.

      Reply
  7. Thank you for your guides.

    You may want to clarify that this guide is for CentOS 7 without any PHP installed, and not an upgrade from PHP 5.4. Unfortunately, this article didn’t work for me, as I have CentOS 7.4.1708 with PHP 5.4.16 already installed.

    Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.