Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»Programming»PHP»How to Check PHP Version (Apache/Nginx/CLI)

    How to Check PHP Version (Apache/Nginx/CLI)

    RahulBy RahulDecember 8, 20203 Mins Read

    PHP (Hypertext Preprocessor) is an popular programming language generally used for the web development. It was originally developed by the Danish-Canadian programmer Rasmus Lerdorf in year 1994. It can be used either via the command line or used with the popular web servers like Apache or Nginx. Apache has PHP module to directly run php files but Nginx required PHP-FPM package to work with PHP files.

    This tutorial will help you to check PHP version installed on your system. Also what is the active version of PHP on command line as well as the check PHP version used by Apache or Nginx. As we can install multiple php versions on single system, it can be the there are different version’s active on CLI and Web servers.

    Check PHP Version (CLI)

    By default there can be one default PHP version can used with standard binary. To check PHP version currently active on command line, execute the following command on terminal:

    php -v 
    
    Output:
    PHP 7.4.8 (cli) (built: Jul 13 2020 16:45:28) ( NTS )
    Copyright (c) The PHP Group
    Zend Engine v3.4.0, Copyright (c) Zend Technologies
        with Zend OPcache v7.4.8, Copyright (c), by Zend Technologies
    

    On Ubuntu and Debian systems, you can also access other version by pointing their versions like: php7.2 or php7.3 etc.

    • Install PHP on Ubuntu 20.04
    • Install PHP on CentOS 8
    • Install PHP on Debian 10

    Check PHP Version (Apache/Nginx)

    Its okay, if the current active php version on command line is different that version used by the Apache or Nginx web servers. It’s also possible that two virtual hosts can use diffrent-2 PHP versions by using PHP-FPM.

    So, to check current active version for Apache or Nginx, navigate to document root of website to which you want to check php verson. For example my document root is /var/www/html:

    cd /var/www/html 
    

    Then create and edit a PHP script file in your favorite text editor:

    vim phpinfo.php 
    

    And, add the following content to the files. Here we used built-in phpinfo() function, which prints the active php version details:

    PHP
    1
    2
    3
    <?php
      phpinfo();
    ?>

    Next, open a web browser and access https://localhost/phpinfo.php url. Update localhost with the IP address or the configured domain name on the system checking php version.

    https://localhost/phpinfo.php

    How to Check PHP Version

    The output will show you all the details related to active PHP along with the PHP version. It will show you the values of the php variables, a list of enabled PHP modules along with there version and other details.

    PHP
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleHow to Install TeamViewer on Ubuntu 20.04
    Next Article date command in Linux with Examples

    Related Posts

    How To Install PHP (8.1, 7.4 or 5.6) on Ubuntu 22.04

    Updated:May 9, 20223 Mins Read

    How To Install Linux, Nginx, MySQL, & PHP (LEMP Stack) on Ubuntu 22.04

    Updated:April 7, 20227 Mins Read

    How To Install LAMP Stack on Ubuntu 22.04 LTS

    Updated:April 20, 20225 Mins Read

    How To Setup Apache, PHP & MongoDB in Ubuntu & Debian

    Updated:October 8, 20213 Mins Read

    How To Install and Use PHP Composer on Debian 11

    Updated:February 16, 20224 Mins Read

    How To Install PHP (8.1, 7.4 & 5.6) on Debian 11

    Updated:February 16, 20224 Mins Read

    Leave A Reply Cancel Reply

    Recent Posts
    • How to Enable / disable Firewall in Windows
    • How to Install JAVA on Ubuntu 22.04
    • Switching Display Manager in Ubuntu – GDM, LightDM & SDDM
    • Changing the Login Screen Background in Ubuntu 22.04 & 20.04
    • How To Install PHP (8.1, 7.4 or 5.6) on Ubuntu 22.04
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.