How To Install PHP 8.x on CentOS 8

How To Install PHP 8.x on CentOS 8

PHP (Hypertext Preprocessor) is known as a general-purpose scripting language that can be used to develop dynamic and interactive websites. It was among the first server-side languages that could be embedded into HTML, making it easier to add functionality to web pages without needing to call external files for data.

Install and configure PHP 8.x on centOS 8; Through this tutorial, we will learn how to install and configure PHP 8.x on CentOS 8.

How To Install PHP 8.x on CentOS 8

Just follow the following steps to install and configure PHP 8.x on CentOS 8:

  • Step 1 – Enable the Remi repository
  • Step 2 – Installing PHP 8 on CentOS
  • Step 3 – Install Apache with PHP 8 on CentOS
  • Step 4 – Configuring PHP to work with Apache

Step 1 – Enable the Remi repository

First of all, open terminal or command line and execute the following command into it to enable the remi repository in centOS 8:

sudo dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm 

sudo dnf install -y https://rpms.remirepo.net/enterprise/remi-release-8.rpm  

sudo dnf module enable php:remi-8.0 -y  

Once the remi repository installation is complete, execute the following command on terminal or command line to get a list of all available PHP versions:

sudo dnf module list php

Step 2 – Installing PHP 8 on CentOS

Now, execute the following command on the command line to install PHP 8 on CentOS:

sudo dnf install php php-opcache php-gd php-curl php-mysqlnd

FPM is installed as a dependency and used as a FastCGI server. Start the FPM service and enable it to automatically start on boot:

sudo systemctl enable --now php-fpm

Step 3 – Install Apache with PHP 8 on CentOS

Execute the following command on terminal or command line to Apache web server on our system:

sudo dnf install httpd -y  

Step 4 – Configuring PHP to work with Apache

 Apache as web server on our system, so restart the httpd service using the following command:

sudo systemctl restart httpd

Now, verity that Apache is read to serve php files over the web. Lets create php info file on your CentOS server. The default virtulhost uses /var/www/html as document root. So create a file under this directory:

echo "<?php phpinfo(); ?>" >  /var/www/html/info.php  

Conclusion

Install and configure PHP 8.x on centOS 8; Through this tutorial, we have learned how to install and configure PHP 8.x on CentOS 8.

Recommended CentOS Tutorials

AuthorAdmin

My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of Tutsmake.com. I like writing tutorials and tips that can help other developers. I share tutorials of PHP, Python, Javascript, JQuery, Laravel, Livewire, Codeigniter, Node JS, Express JS, Vue JS, Angular JS, React Js, MySQL, MongoDB, REST APIs, Windows, Xampp, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL and Bootstrap from a starting stage. As well as demo example.

Leave a Reply

Your email address will not be published. Required fields are marked *