Step by step guide on installing PHP 8.0 on CentOS 8 | CentOS 7
PHP 8.0 is the latest version of the popular server-side scripting language that powers many websites and web applications. In this blog post, we’ll go over how to install PHP 8.0 on CentOS 8 and CentOS 7.
Before we get started, make sure that you have a non-root user account with sudo privileges.
Installing PHP 8.0 on CentOS 8
Follow these steps to install PHP 8.0 on CentOS 8:
Step 1: Add the Remi repository
PHP 8.0 is not included in the default CentOS 8 repository. We need to add the Remi repository to get the latest version of PHP.
Use the following command to add the Remi repository:
sudo dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm
Step 2: Enable the Remi repository
Once the Remi repository is added, we need to enable it. Use the following command to enable the Remi repository:
sudo dnf module reset php
sudo dnf module enable php:remi-8.0
Step 3: Install PHP 8.0
Now that the Remi repository is enabled, we can install PHP 8.0 using the following command:
sudo dnf install php
Step 4: Verify the installation
To verify that PHP 8.0 is installed and running, create a test PHP file with the following command:
sudo nano /var/www/html/info.php
Add the following code to the file:
<?php
phpinfo();
?>
Save and close the file.
Now, open a web browser and navigate to http://<your_server_ip>/info.php
. You should see the PHP information page, which confirms that PHP 8.0 is installed and running.
Installing PHP 8.0 on CentOS 7
Follow these steps to install PHP 8.0 on CentOS 7:
Step 1: Add the Remi repository
Use the following command to add the Remi repository to CentOS 7:
sudo rpm -Uvh https://rpms.remirepo.net/enterprise/remi-release-7.rpm
Step 2: Enable the Remi repository
Once the Remi repository is added, we need to enable it. Use the following command to enable the Remi repository:
sudo yum-config-manager --enable remi-php80
Step 3: Install PHP 8.0
Now that the Remi repository is enabled, we can install PHP 8.0 using the following command:
sudo yum install php
Step 4: Verify the installation
To verify that PHP 8.0 is installed and running, create a test PHP file with the following command:
sudo nano /var/www/html/info.php
Add the following code to the file:
<?php
phpinfo();
?>
Save and close the file.
Now, open a web browser and navigate to http://<your_server_ip>/info.php
. You should see the PHP information page, which confirms that PHP 8.0 is installed and running.
Conclusion
In this blog post, we’ve gone over how to install PHP 8.0 on CentOS 8 and CentOS 7 using the Remi repository. By following these steps, you can get the latest version of PHP up and running on your CentOS server in no time.
Some important study notes