Which php version linux

How to check the PHP version on Linux

There are several possibilities to check and validate PHP version on Linux.

1. Open a bash shell terminal and use the command “php –version” or “php -v” to get the version of PHP installed on the system.

# php --version PHP 5.4.16 (cli) (built: Mar 7 2018 13:34:47) Copyright (c) 1997-2013 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
# php -v PHP 5.4.16 (cli) (built: Mar 7 2018 13:34:47) Copyright (c) 1997-2013 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

As you can see from both the command output above, the system has PHP 5.4.16 installed.

2. You can also check for the package versions installed on the system to get the PHP version.
On RedHat Based Distributions :

# rpm -qa | grep php php-common-5.4.16-43.el7_4.1.x86_64 php-pdo-5.4.16-43.el7_4.1.x86_64 php-mysql-5.4.16-43.el7_4.1.x86_64 php-mbstring-5.4.16-43.el7_4.1.x86_64 php-cli-5.4.16-43.el7_4.1.x86_64 php-gd-5.4.16-43.el7_4.1.x86_64 php-5.4.16-43.el7_4.1.x86_64

On debian based distributions :

# apt list --installed | grep php

3. Let’s create a PHP file with content as shown below. The phpinfo() function outputs a great deal of information about the state of the current PHP environment, including loaded extensions, compilation options, version, server information, and so on.

# echo "<?php phpinfo();?>" > /var/www/html/phpinfo.php

4. Now, considering that Apache is installed and working, open a browser and test PHP using address as follow:

how to check PHP version in Linux

Источник

How to check PHP version on Ubuntu

After installing PHP or an entire LAMP server on Ubuntu Linux, there are a few ways you can check to see what version you’re running at any time. This can help you stay up to date and develop web applications that adhere to newer coding standards and conventions, since PHP is still being developed.

In this guide, we’ll show you multiple ways to check the version of PHP on Ubuntu. Feel free to pick whichever method is most convenient for your situation.

In this tutorial you will learn:

Checking PHP version on Ubuntu Linux

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Ubuntu Linux
Software PHP
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

Check PHP version

$ php -version PHP 7.4.3 (cli) (built: May 26 2020 12:24:22) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies
$ php -a Interactive mode enabled php > phpinfo(); phpinfo() PHP Version => 7.4.3 . php > exit

phpinfo PHP page accessed from web browser

Conclusion

In this tutorial, we saw three different methods for checking the PHP version on Ubuntu. Some methods are quicker, and some supply additional configuration information. Using one or more of the methods here should give you all the information you need about your PHP install.

Читайте также:  Red hat linux with vmware

NEWSLETTER

Subscribe to Linux Career Newsletter to receive latest news, jobs, career advice and featured configuration tutorials.

WRITE FOR US

LinuxConfig is looking for a technical writer(s) geared towards GNU/Linux and FLOSS technologies. Your articles will feature various GNU/Linux configuration tutorials and FLOSS technologies used in combination with GNU/Linux operating system.

When writing your articles you will be expected to be able to keep up with a technological advancement regarding the above mentioned technical area of expertise. You will work independently and be able to produce at minimum 2 technical articles a month.

TAGS

  • VIM tutorial for beginners
  • How to install the NVIDIA drivers on Ubuntu 20.04 Focal Fossa Linux
  • Bash Scripting Tutorial for Beginners
  • How to check CentOS version
  • How to find my IP address on Ubuntu 20.04 Focal Fossa Linux
  • Ubuntu 20.04 Remote Desktop Access from Windows 10
  • Howto mount USB drive in Linux
  • How to install missing ifconfig command on Debian Linux
  • AMD Radeon Ubuntu 20.04 Driver Installation
  • Ubuntu Static IP configuration
  • How to use bash array in a shell script
  • Linux IP forwarding – How to Disable/Enable
  • How to install Tweak Tool on Ubuntu 20.04 LTS Focal Fossa Linux
  • How to enable/disable firewall on Ubuntu 18.04 Bionic Beaver Linux
  • Netplan static IP on Ubuntu configuration
  • How to change from default to alternative Python version on Debian Linux
  • Set Kali root password and enable root login
  • How to Install Adobe Acrobat Reader on Ubuntu 20.04 Focal Fossa Linux
  • How to install the NVIDIA drivers on Ubuntu 18.04 Bionic Beaver Linux
  • How to check NVIDIA driver version on your Linux system
  • Nvidia RTX 3080 Ethereum Hashrate and Mining Overclock settings on HiveOS Linux

LATEST TUTORIALS

  • Easy Steps to Update Your Raspberry Pi
  • Connecting Your Raspberry Pi to Wi-Fi: A How-To
  • How to install RealVNC viewer on Linux
  • How to check Raspberry Pi RAM size and usage
  • How to check Raspberry Pi model
  • Understanding UEFI and BIOS in Relation to Linux Nvidia Driver Installation
  • How to orchestrate Borg backups with Borgmatic
  • How to monitor filesystem events on files and directories on Linux
  • Debian USB Firmware Loader Script
  • How to install and self host an Ntfy server on Linux
  • How to backup your git repositories with gickup
  • How to bind an SSH public key to a specific command
  • Creating a Bootable USB for Windows 10 and 11 on Linux
  • How to list all displays on Linux
  • List of QR code generators on Linux
  • How to extract text from image
  • Linux EOF explained
  • How to use xclip on Linux
  • List of window managers on Linux
  • What is zombie process on Linux
Читайте также:  Linux cat нумерация строк

Источник

How to Check PHP Version

Hosting providers are traditionally slow to adopt new PHP versions on their servers. The consequence of this is that many different PHP versions exist on the web at the same time.

If you are implementing new features, installing a new PHP-based app, or trying to locate a bug on your website, it is important to know which PHP version your web server is running.

In this tutorial, you will learn how to check your PHP version by running PHP code on your server or using the command line.

How to Check PHP Version

Check PHP Version by Running PHP Code

The simplest method to determine the PHP version running on your website is executing a PHP file that contains the following code:

Create the file using a text editor like gedit or Notepad, and upload it to your website’s document root directory.

Then open a web browser and type the full address of the file in the address bar. For example, if you uploaded a file titled phpinfo.php to the example.com root directory, you would go to:

http://www.example.com/phpinfo.php

The code above displays the PHP version without any further details, like in the output below:

Checking PHP version by using the phpversion command

If you need more details on your PHP configuration, such as system information, build date, server API, configuration file information, etc., upload a file containing the phpinfo() function:

When visited in the browser, this file shows the PHP version in the upper-left corner, followed by configuration data:

Checking PHP version by using the phpinfo command

Note: While phpinfo() is useful for debugging, the page features sensitive information about your system. Remove the file from the server once you finish using it.

For a list containing all the loaded PHP extensions and their versions, upload a file with the following code:

The output shows each extension in a separate line, including the version of the PHP core:

Checking versions of loaded PHP extensions

Check PHP Version Using the Command Line (Windows, Linux and macOS)

If you have permission to SSH into the remote server, use the command line to check the installed PHP version. This method is also useful for checking the PHP version installed locally.

2. The php -v command works on Linux, macOS, Windows, and other supported systems. Its output contains the PHP version number, build date, and copyright information.

Checking PHP version by using the command line in Ubuntu

Note: If there is more than one PHP version installed on the server, the php -v command shows the default command-line interface (CLI) version. This version is not necessarily the one that runs on the hosted websites.

Fix ‘PHP is not Recognized’ Error on Windows

On Windows, the PHP path is sometimes not recognized by the system, so the php -v command outputs the ‘php is not recognized’ error.

Читайте также:  Linux asp net mvc

The

To solve this problem, set the PATH environment variable first.

1. Type the following command, replacing [location] with the path to your PHP installation.

Setting the PATH variable for php.exe in Windows

2. Typing php -v now shows the PHP version installed on your Windows system.

Note: Check out our other PHP guides such as How to Make a Redirect in PHP or 4 Different Types of Errors in PHP.

This article aimed to explain the common ways to check the PHP version on your server or local machine. The methods covered in this tutorial include running PHP code and using the command-line interface.

Marko Aleksić is a Technical Writer at phoenixNAP. His innate curiosity regarding all things IT, combined with over a decade long background in writing, teaching and working in IT-related fields, led him to technical writing, where he has an opportunity to employ his skills and make technology less daunting to everyone.

A PHP Error occurs when something is wrong in the PHP code. An error can be simple as a missing semicolon.

If a script is not written correctly, or if something unusual happens, PHP can generate an error message.

Источник

Как узнать версию php

Язык программирования PHP — один из самых популярных языков для создания веб-сайтов и различных веб-приложений. Когда вы устанавливаете какую-либо систему управления контентом, например, WordPress, Joomla, ModX или что-либо другое, обычно у них есть требование к минимальной версии PHP.

Поэтому часто бывает необходимо узнать версию PHP, установленную на сервере. Это можно сделать несколькими способами, но в обоих случаях у вас должен быть доступ к серверу.

Просмотр версии в терминале

Для того чтобы узнать установленную версию PHP в терминале надо иметь SSH доступ к серверу. Подключитесь к серверу по SSH и выполните такую команду:

Утилита покажет информацию о сборке PHP, а также её версию. Однако, такой способ позволяет узнать версию используемую по умолчанию в консоли или php-cli. Если вы используете какую-либо панель управления сервером, то обычно панели устанавливают свои версии PHP отдельно в папку /opt. Чтобы посмотреть версию PHP установленной панелью надо использовать браузер.

Просмотр версии в браузере

Подключитесь по FTP или по SSH к серверу и перейдите в корневой каталог вашего сайта. Там создайте небольшой скрипт со следующим содержимым:

Затем откройте ваш сайт и допишите в адресной строке адрес этого файла:

Если всё сделано верно, будет выведена огромная таблица с информацией про PHP и установленные расширения, а в самом верху страницы будет версия PHP.

Если вы не хотите выводить всю таблицу с информацией о PHP, то можно вывести только версию с помощью функции phpversion. Например:

Тогда, в результате вы получите такую страницу:

Как видите, проверить версию PHP не так уже и сложно. А какие способы знаете вы? Напишите в комментариях!

Обнаружили ошибку в тексте? Сообщите мне об этом. Выделите текст с ошибкой и нажмите Ctrl+Enter.

Источник

Оцените статью
Adblock
detector