Home  >  Article  >  Operation and Maintenance  >  How to check installed php version information in linux

How to check installed php version information in linux

PHPz
PHPzOriginal
2023-03-24 16:06:271073browse

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.

  1. Use the php -v command

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 is PHP 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.

  1. View PHP configuration file

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 folder 7.3, so we can be sure that we are using version 7.3 of PHP.

Enter the 7.3 folder and view the cli folder, which stores the configuration file used when running the PHP command line. In the cli folder, you can find the PHP configuration file php.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 the version line above. Here, we can see that the PHP version is 7.3.9-1~deb10u1.

  1. View in phpinfo()

In addition to the methods introduced earlier, you can also run PHP on the Apache or Nginx server phpinfo() Function to view PHP version information.

First, create a file named phpinfo.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 URL http://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 the phpinfo() 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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn