Use apt-get or yum to install PHP.
yum install php
Create the phpinfo.php file in the document root of your web server.
Add the following to the phpinfo.php file.
<?php phpinfo(); ?>
Make the following changes to the /etc/php.ini file. The reason open_basedir is set to /var/www instead of /var/www/html is because if HTTPD will be producing two or more websites using virtual hosts, setting open_basedir to /var/www ensure that every site at and below /var/www can use PHP.
expose_php = Off open_basedir = /var/www
The ps command can be used to determine if your system is using init or systemd. If PID 1 is init, then you will use the service command. If PID 1 is systemd, then you will use the systemctl command.
If your system is using systemd, use the systemctl command to start and enable httpd.
systemctl restart httpd systemctl status httpd
service httpd restart service httpd status
Navigate to www.example.com/phpinfo.php, and the PHP info page should be displayed.