How to Install PHP on CentOS 8
Enjoying this content? Subscribe to the Channel!
Lightning Fast: How to Install PHP on CentOS 8 (The One-Command Guide)
Hi there, and welcome back to Darren’s Tech Tutorials!
If you’re setting up a new server environment on CentOS, one of the most essential components you need is PHP—the engine that powers most of the web’s dynamic content, including WordPress and countless other applications.
The great news is that installing PHP on CentOS 8 is an incredibly fast, straightforward process that takes just a single command. We’re going to run through this setup quickly, ensuring you get PHP installed and verified on your server in minutes.
Ready? Let’s dive in!
Compatibility Check: Who Can Use This Guide?
While this tutorial focuses primarily on CentOS 8, the simple yum install command we are using is highly flexible and works across multiple Red Hat-based distributions.
This installation method is also confirmed to work flawlessly on:
- CentOS 7
- Red Hat Enterprise Linux (RHEL)
If you are running any of these versions, you can follow along exactly!
Step 1: The Single Command Installation
We prioritize simplicity here at Darren’s Tech Tutorials. We won’t be messing with extensive package lists or complicated repository setups for the basic installation. We are going to use the yum package manager to fetch and install the latest available stable PHP version directly.
To begin the installation, open your terminal and execute the following command:
sudo yum install php
What Happens Next?
- Package Confirmation: After running the command, the system will identify the necessary core PHP packages and any essential dependencies required to run PHP.
- Accepting the Installation: You will be prompted to accept the installation and confirm that you want to download and install these packages. Type
yand hit Enter to continue. - Download and Install: The system will now download the files and configure PHP on your CentOS 8 server. This process is usually very quick!
Step 2: Verifying the PHP Installation
Once the command finishes running and your terminal returns to the prompt, PHP should be successfully installed.
However, a good server administrator always verifies their work! We need to confirm that PHP is running correctly and check which version was installed.
To verify the installation, run the following simple version check command:
php -v
Expected Output
If the installation was successful, you should see output similar to this:
PHP 7.2.xx (cli) (built: Month Day Year Time) (NTS)
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
As you can see, the default installation on our CentOS 8 system successfully pulled PHP 7.2. Congratulations, you now have a functional version of PHP ready to power your server applications!
Wrapping Up
See? We told you it was incredibly easy! Installing the base PHP package on CentOS 8 is a lightning-fast process that requires almost zero configuration.
Now that PHP is ready, you can move on to installing your web server (like Apache or Nginx) and deploying your dynamic web applications.
If this very short tutorial was helpful in getting you started, please do us a huge favor: Like this post and Subscribe to Darren’s Tech Tutorials for more clear, accessible technology guides.
As always, thank you for watching (and reading)! Happy coding!