How to install PHP for HTTPD in Linux

Home > Search > How-to
  by

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

 

Restart HTTPD.

[root@server1 ~]# systemctl restart httpd

 

Navigate to www.example.com/phpinfo.php, and the PHP info page should be displayed.



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter in the box below so that we can be sure you are a human.




Comments