Home  >  Article  >  Operation and Maintenance  >  How to install and configure PHP on Red Hat Enterprise Linux7.4

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

WBOY
WBOYforward
2023-05-23 12:08:411470browse

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.

  1. Use the root user to log in to the RHEL 7.4 server.

  2. Use the following yum command to update system packages:

yum update -y
  1. Install the Apache web server with root privileges:

yum install httpd -y
  1. 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
  1. 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.

  1. Use the following commands to install PHP and related MySQL and Apache modules:

yum install php php-mysql php-gd -y
  1. After installation is complete, use the following Command to restart the web server for the changes to take effect:

systemctl restart httpd
  1. To verify that PHP is installed and configured correctly, create an index.php file:

vi /var/www/html/index.php
  1. Insert the following PHP code into the index.php file:


    <?phpphpinfo(); ?>
    


  2. 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!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete