Step One: Install and Configure 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.
Use the root user to log in to the RHEL 7.4 server.
Use the following yum command to update system packages:
yum update -y
Install the Apache web server with root privileges:
yum install httpd -y
After the installation is complete, use the following systemctl command to start the Apache web server and configure it to start at boot:
systemctl start httpd systemctl enable httpd
Access 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 move on to installing and configuring PHP.
Use the following commands to install PHP and related MySQL and Apache modules:
yum install php php-mysql php-gd -y
After 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 installed and configured correctly, create an index.php file:
vi /var/www/html/index.php
Insert the following PHP code into the index.php file:
<?phpphpinfo(); ?>
Save and exit the file, then enter your server IP address into your web browser and you should see the PHP information page. The PHP version, compilation options, and all loaded PHP modules will be listed on the page.
The above is the detailed content of How to install and configure PHP on Red Hat Enterprise Linux7.4. For more information, please follow other related articles on the PHP Chinese website!