FreeKB - HTTPD Install PHP on Linux
HTTPD - Install PHP on Linux

Use apt-get or yum to install PHP.

yum install php


Create the phpinfo.php file in the document root of your web server.

touch /var/www/html/phpinfo.php


Add the following to the phpinfo.php file.



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


If your system is using init, use the chkconfig and service commands to start and enable httpd.

service httpd restart
service httpd status


Navigate to, 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 5ea64 in the box below so that we can be sure you are a human.


Web design by yours truely - me, myself, and I   |   |