To install and test PHP on a Linux system, follow these steps:
apt-get
command:sudo apt-get update sudo apt-get install php
On a Red Hat-based system, you can use the yum
command:
sudo yum update sudo yum install php
test.php
in a directory that is accessible by the web server. The file should contain the following code:<?php phpinfo(); ?>
To view the output of this script, open a web browser and go to the URL of the test.php
file. For example, if the test.php
file is located in the root directory of your web server, you can access it at http://localhost/test.php
.
If PHP is installed and working correctly, you should see a page containing information about your PHP installation.