How to Install PHP 7.4 with Nginx in RHEL 8

How to Install PHP 7.4 with Nginx in RHEL 8
How to Install PHP 7.4 with Nginx in RHEL 8

How to Install PHP 7.4 with Nginx in RHEL 8 - Hi everyone, Back at kitsake.com, this time I will write and share my experience in the Linux world, in this article, I will discuss how to install PHP with Version 7.4.

Setting up PHP 7.4 with Nginx on Red Hat Enterprise Linux 8 (RHEL 8) involves a series of steps to ensure a seamless integration of the web server and the PHP scripting language. This powerful combination provides a robust platform for hosting dynamic websites and applications.

In this guide, we will walk through the installation process, detailing each step to help users effectively configure PHP 7.4 with Nginx on RHEL 8. Whether you are a system administrator or a developer looking to optimize your web server environment, this article will provide comprehensive instructions to facilitate a successful installation and configuration.

The installation method is quite simple, it only takes a few steps.

Preparation

For the first step, you must install the epel repo, for the command can be seen below :

# dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
# dnf install dnf-utils http://rpms.remirepo.net/enterprise/remi-release-8.rpm

Install Epel Repo
Install Epel Repo

You just have to activate the epel repo to 7.4 so that later when you install php, what is installed on your server is version 7.4.

# dnf module list php
# dnf module list reset php -y
# dnf module enable php:remi-7.4
Activated remi php 7.4
Activated remi php 7.4

After installing the epel repo, you can proceed to the install section.

Installing PHP 7.4

Keep in mind because I'm a Nginx user I installed php which needs Nginx, namely php-cli, if you are an Apache user you can just install PHP.

In the command below I immediately installed php and the modules that I usually use.

# dnf install php-cli php-pear php-devel php-fpm php-curl php-mysqlnd php-gd php-opcache php-zip php-intl php-common php-bcmath php-imap php-imagick php-xmlrpc php-json php-readline php-memcached php-redis php-mbstring php-apcu php-xml php-devel -y

RHEL 8 Install PHP 7.4
Proses Install PHP and Module

You can see with the version check command to make sure PHP has been installed on our server.

Trying

To ensure the correct installation, you can verify by checking the installed PHP version. Open your terminal or command prompt and type the command "php -v" to display the installed PHP version.

# php -v

This will confirm that the installation was successful and provide you with the details of the PHP version currently running on your system.

Check Version of PHP
Check the Version of PHP

Configure

Basically, PHP will run with the root user, because I want to change the PHP to run as the nginx user I changed to nginx for the method as below;

# ps -aux |grep php-fpm

Before change to Nginx
Before the change to Nginx

Modify the configuration file ww.conf to look like the one below:

# vi /etc/php-fpm.d/www.conf
; RPM: apache user chosen to provide access to the same directories as httpd
user = nginx
; RPM: Keep a group allowed to write in log dir.
group = nginx

After making changes, it is necessary to restart the service so that the configuration files modified in the previous step can take effect properly.

# systemctl restart nginx
# systemctl restart php-fpm

Next, check again whether PHP is running with the 'nginx' user as expected or not.

# ps -aux |grep php-fpm

After change to Nginx
After changing to Nginx

Closing statement

In conclusion, installing PHP 7.4 with Nginx on Red Hat Enterprise Linux 8 not only enhances the performance of web applications but also ensures a secure and efficient server environment. 

By following the steps outlined in this guide, users can leverage the latest features and improvements offered by PHP 7.4 while harnessing the power and flexibility of Nginx as the web server. 

Keeping both components up-to-date is crucial for maintaining a stable and reliable web hosting infrastructure. As technology continues to evolve, staying informed about the latest updates and best practices will contribute to the overall success of web development projects on the RHEL 8 platform.

And that's my experience when I installed PHP 7.4 with nginx on RHEL 8. I hope this article can be useful for all of you.

That is all and thank you.

Bangkit Ade Saputra
Bangkit Ade Saputra At the end of the day, my job involves people. we're complicated, we're always changing, we have millions of things going on in our lives, and changing jobs is always a big decision.

Post a Comment for "How to Install PHP 7.4 with Nginx in RHEL 8"