Sometimes when you’re configuring PHP, you need to confirm what Apache is actually serving – not what you think its serving. The below trick will confirm PHP is working and what version is being served.
Assuming you’ve already configured a virtual host so serve PHP, create a file within the document root.
[email protected]:/var/www/mywebsite/public# [email protected]:/var/www/mywebsite/public# vim info.php
Enter the following information.
<?php phpinfo(); ?>
If PHP is being served by Apache correctly, you should be able to navigate to that page:
And see something similar to the below.
If this page is not being displayed correctly, Apache is not serving PHP correctly. If it is, you should be able to see all the relevant information relating to the PHP version being served. For example, the version, the loaded configuration file, what modules are currently loaded, etc.
Note – this information provides a security risk and should not be left in place. Especially if this is on the public internet. If you want to leave a test in place but don’t want to expose sensitive information, you could use the PHP
echo function by replacing the contents of
<?php echo "PHP Test Successful"; ?>
If not, make sure you remove it:
[email protected]:/var/www/snipe-it/public# rm info.php
Be the first to comment