How to check installed php version information in linux

PHPz
Release: 2023-03-24 16:25:44
Original
1154 people have browsed it

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
Copy after login

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
Copy after login

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.

  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/phpfolder, as shown below:

/etc/php/ ├── 7.3 │ ├── apache2 │ │ ├── php.ini │ │ ├── php.ini~ │ ├── cli │ │ ├── php.ini │ │ ├── php.ini~
Copy after login

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.3folder and view theclifolder, which stores the configuration file used when running the PHP command line. In theclifolder, 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
Copy after login

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
Copy after login

The version information is in theversionline above. Here, we can see that the PHP version is7.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 serverphpinfo()Function to view PHP version information.

First, create a file namedphpinfo.phpon the server with the following content:

Copy after login

After saving and uploading the file, access the file. View the PHP version and other related information. Enter the URLhttp://yourdomain.com/phpinfo.phpin 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!

Related labels:
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!