How to View or Check PHP Version on Linux – PHP is one programming language the most widely used server-side. PHP is a general purpose programming language that was originally designed for web development. Originally created by Rasmus Lerdorf in 1994; PHP reference implementations are now produced by The PHP Group. But now stands for PHP recursive initialism: Hypertext Preprocessor. There are some important differences between PHP versions, so knowing which version is running on your server may be necessary in some situations.
For example, if you are upgrading an application or web platform with a new version, there are times when they need a certain PHP version before starting the installation to run normally, you must know your PHP server version. And upgrading PHP version to newer will also increase processing speed and be more stable.
In this article, I will show you how to view or check the version of PHP on linux running on your server.
Check the PHP version with
The most reliable way to find out what version of PHP is used for a particular website is to use a function
phpinfo(), which prints various information about the PHP server, including its version.
In your website document root directory upload the following PHP files using FTP client or SFTP:
Open web browser beloved, open it
yourdoman.com/phpinfo.php, and the PHP server version will be displayed on your screen:
Once you know which version of PHP you have, delete the files or restrict access. Publicly exposing your PHP configuration to pose a security risk to your application.
There are also other functions you can use to find out the PHP version. Unlike
phpversion() just print the PHP server version.
<?php echo 'PHP version: ' . phpversion();
Check the PHP version of the Command Line
If you have access SSH to the server, you can use the PHP CLI binaries to determine your PHP version.
To get server version enable php binary using options
$ php --version
The command will display information about the PHP version and exit. In this example the PHP server version is
Output PHP 7.3.11-1~deb10u1 (cli) (built: Oct 26 2019 14:14:18) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.3.11, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.3.11-1~deb10u1, Copyright (c) 1999-2018, by Zend Technologies
If there are multiple PHP versions installed on the server, when you run the php command, it will display the default PHP CLI version, which may not be the PHP version used on the website.
Determining the PHP server version is a relatively straightforward task. However you should keep on learning this as it is often used when there is a web application you need and they want a specific version of PHP to run it.
In this guide, I have shown you a few different options on how to view and check which version of PHP on linux is running on your server.