So we have seen how we can test the web server and the MySQL server, we of course, can test the PHP installation as well. In its simplest for we can run PHP as a script interpreter from the command line
echo "Hello worldn"; ?>
As with all scripts on Linux we will need to make this executable with the command
chmod +x test2.php
This OK, it has shown that PHP works and it is true, some admins omit PHP as a command line script interpreter, in reality it is very similar to PERL and there is no real need for it on the CLI, command line environment. I am sure that we have PHP on our web server because we wish to run dynamic web content on our server. There is a simple function in PHP called : phpinfo.
We can run this from a web page with just this code and this code alone in a .php document:
<?php phpinfo(); ?>
We can access the page as:
We should see an extensive page displaying information about the web server and PHP installed on the server. If the page does not open and the PHP file is prompted to be saved locally it may be that the apache server does not have the PHP module loaded. On our test server we are using SUSE and the apache modules are loaded from the file /etc/sysconfig/apache2 . On other systems the odules is more tradtionally loaded by a LoadModule statement in the httpd.conf: similar to the following
LoadModule php5_module /usr/lib/httpd/modules/libphp5.so
If you are not sure where the module is located then you can use the find command as on the my CentOS system below.
If you do have to add the module to the apache server even on SUSE or others distributions then the web server will need to be rebooted.