PHP is a widely used open-source programming language that powers many websites and web applications. It is constantly evolving, with new versions being released regularly. As a system administrator, system developer or webmaster, it is important to know which version of PHP is running on your server to ensure compatibility and security. In this article, we will discuss how to check the PHP version in Linux step-by-step.
Steps by Step on How to check the PHP version on Linux
Step 1: Open the Terminal
Open the terminal on your Linux system by pressing the Ctrl+Alt+T key combination.
Step 2: Check PHP Version with Command Line
Once you have opened the terminal, you can check the PHP version by typing the following command:
# php -v
Example output :
This command will show you the version of PHP installed on your system.
Step 3: Check PHP Version via phpinfo()
You can also check the PHP version by creating a phpinfo() file on your server. Here are the steps to follow:
Create a new file named “phpinfo.php” in the web server’s root directory, for example, /var/www/html/phpinfo.php
Add the following line to the file:
<?php phpinfo(); ?>
a) Save and close the file.
b) Access the file through a web browser by visiting http://yourdomain.com/phpinfo.php
c) The page that opens will display all the information about the PHP version installed on your system, including the version number.
Step 4: Check PHP Version via Command Line Interface (CLI)
You can also check the PHP version via the command-line interface (CLI). Here are the steps to follow:
a) Open the terminal.
b) Type the following command:
# php -r 'echo PHP_VERSION . "\n";'
Example output :
c) Press Enter. The version number of PHP installed on your system will be displayed.
As a system administrator, system developer, or webmaster, it is essential to know which version of PHP is running on your linux server to ensure compatibility and security. In this article, we have discussed how to check the PHP version in Linux step-by-step. You can use any of the methods described above to determine the PHP version installed on your system. By following these steps, you can ensure that your website or web application is running on the most secure and up-to-date version of PHP.