In a Linux system, how to check the installed PHP version information? This is a very common problem and this article will provide you with the solution to this problem.
In the Linux terminal or console, you can use the following command to view the PHP version currently installed on the system:
php -v
Using this command will output results similar to the following on the screen:
PHP 7.3.9-1~deb10u1 (cli) (built: Sep 18 2019 11:58:52) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.3.9, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.3.9-1~deb10u1, Copyright (c) 1999-2018, by Zend Technologies
Among them, the first line shows the installed PHP version, here isPHP 7.3.9-1~ deb10u1
. In addition, you can also see the copyright statement of PHP, as well as version information of the engine and caching components used.
In addition to using the command line command, you can also directly view the PHP configuration file. In most Linux systems, the PHP configuration file is located in the/etc/php
folder, as shown below:
/etc/php/ ├── 7.3 │ ├── apache2 │ │ ├── php.ini │ │ ├── php.ini~ │ ├── cli │ │ ├── php.ini │ │ ├── php.ini~
In this folder, you can find the PHP you installed version folder. Here, we see the folder7.3
, so we can be sure that we are using version 7.3 of PHP.
Enter the7.3
folder and view thecli
folder, which stores the configuration file used when running the PHP command line. In thecli
folder, you can find the PHP configuration filephp.ini
.
Use the following command to open the configuration file:
sudo nano /etc/php/7.3/cli/php.ini
Next, look for; version=
in the file, and you can see the version information below it:
; This is used to disable loading of OPcache extension. ; zend_extension=opcache.so version=7.3.9-1~deb10u1
The version information is in theversion
line above. Here, we can see that the PHP version is7.3.9-1~deb10u1
.
In addition to the methods introduced earlier, you can also run PHP on the Apache or Nginx serverphpinfo()
Function to view PHP version information.
First, create a file namedphpinfo.php
on the server with the following content:
After saving and uploading the file, access the file. View the PHP version and other related information. Enter the URLhttp://yourdomain.com/phpinfo.php
in the browser, you will see a page similar to the following:
In this page, you can find the PHP version and other Related Information.
Conclusion
This article introduces three methods to view installed PHP version information. You can check your PHP version using a command line command, viewing the PHP configuration file, or using thephpinfo()
function on the server. Using one of these methods, you can easily determine your PHP version and update or upgrade it if necessary.
The above is the detailed content of How to check installed php version information in linux. For more information, please follow other related articles on the PHP Chinese website!