How to install and configure PHP on Red Hat Enterprise Linux7.4

10-10-2023

Step 1: Install and configure the Apache Web server. Before installing PHP, we need to verify that the Apache Web server is installed and running. The process of installing and configuring Apache Web server on RHEL 7.4 is as follows.

Log in to the RHEL 7.4 server with root user.

Use the following yum command to update the system package:

yum update -y

Install Apache Web server with root privileges:

yum install httpd -y

After the installation is completed, use the following systemctl command to start the Apache Web server and configure it to boot:

systemctl start httpdsystemctl enable httpd

Visit your server IP address in a Web browser. If the Apache test page appears, the Apache server has been successfully installed and configured.

Step 2: Install PHP Now that we have successfully installed and configured the Apache Web server, let's continue to install and configure PHP.

Use the following command to install PHP and related MySQL and Apache modules:

yum install php php-mysql php-gd -y

After the installation is complete, use the following command to restart the Web server for the changes to take effect:

systemctl restart httpd

To verify that PHP is properly installed and configured, please create a index.php file:

vi /var/www/html/index.php

Insert the following PHP code into the index.php file:

Copyright Description:No reproduction without permission。

Knowledge sharing community for developers。

Let more developers benefit from it。

Help developers share knowledge through the Internet。

Follow us