Use apt-get or yum to install PHP.
[root@server1 ~]# yum install php
Create the phpinfo.php file in the document root of your web server.
[root@server1 ~]# touch /var/www/html/phpinfo.php
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
[root@server1 ~]# systemctl restart httpd
Navigate to www.example.com/phpinfo.php, and the PHP info page should be displayed.