Need help? Chat now!
Search results for:
Table of Contents
Creating a simple PHP info page is a great way to test your server's PHP processing capabilities. This will not only confirm that PHP is installed and working as expected but will also allow you to see what modules are installed and active on your server. The focus of this article is to teach you how to create and use a PHP info page. Once this page is created, you can either leave it in place for future consultation or remove it together. This article implies that you have already installed PHP on your server, however, if you have not yet done so, please review the following articles, which cover the installation of PHP in CentOS 7 or Ubuntu 14.04:
Before getting started, you'll need to access your server using SSH. If you're not familiar with how to do this, or you love to read, please take a moment and read through the following article: Connecting to Your Server via SSH. Once you have connected to your server via SSH, you can proceed. Also, creating the PHP info page will require you to use your favorite Linux text editor. Wait, what's this? You don't have a favorite Linux text editor? No problem, we've got you covered with the following article: How to Edit Files from a Linux Shell. For this article, I will be using nano (it's my favorite). Now that you're connected to your server via SSH and have a favorite Linux text editor in mind to use let's get create the PHP info page!
We will essentially create a PHP script that will execute when you navigate to the page in your web browser. To do this, you'll need to create the file in your website's webroot. This can be a few different places depending on if you're using a control panel like cPanel or not. I am using a CentOS 7 server with no control panel for this article, so my webroot is located at /var/www/html/. With that in mind, the command I would then run to create the info.php file using nano is:
With the file now open, you'd enter in the following code:
Please save and close the file once you're satisfied with the edits that you have made. Test if the file and php are both working navigate to the file in your web browser. If you created this file under your website, this would be:
You should also be able to use your IP address followed by info.php:
You should see a page similar to the following image:
If you see this page, congratulations, this indicates that PHP is installed and is working correctly! You can also use this page to make sure any settings you have changed are being applied and help you with debugging.
Written by Michael Brower / June 22, 2017