{"id":9841,"date":"2021-11-07T13:54:18","date_gmt":"2021-11-07T18:54:18","guid":{"rendered":"http:\/\/prod.main.brightwhiz.com\/?p=9841"},"modified":"2021-12-03T13:28:28","modified_gmt":"2021-12-03T13:28:28","slug":"get-active-major-minor-and-release-php-version-in-linux","status":"publish","type":"post","link":"http:\/\/local.brightwhiz\/get-active-major-minor-and-release-php-version-in-linux\/","title":{"rendered":"How to get Active Major, Minor, and Release PHP Version in Linux"},"content":{"rendered":"\n

You can find the active major, minor, and release PHP version in Linux servers with simple commands. There are two simple solutions using the PHP command-line with additional parameters.<\/p>\n\n\n\n

1. Get the PHP Version Using PHP + GREP + CUT<\/h2>\n\n\n\n
$ php -v | grep ^PHP | cut -d' ' -f2<\/code><\/pre>\n\n\n\n

Will return output similar to this:<\/p>\n\n\n\n

8.0.12<\/code><\/pre>\n\n\n\n

2. Get the PHP Version Using PHP + INTERNAL PHP_VERSION CONSTANT<\/h2>\n\n\n\n
$ php -r 'echo PHP_VERSION."\\n";'<\/code><\/pre>\n\n\n\n

Will return output similar to this:<\/p>\n\n\n\n

8.0.12<\/code><\/pre>\n\n\n\n

In the above example you can use these other PHP constants listed here:<\/p>\n\n\n\n

  • PHP_MAJOR_VERSION (int)<\/li>
  • PHP_MINOR_VERSION (int)<\/li>
  • PHP_RELEASE_VERSION (int)<\/li>
  • PHP_VERSION_ID (int)<\/li>
  • PHP_EXTRA_VERSION (string)<\/li><\/ul>\n\n\n\n

    Example: In the above examples the Major, Minor, and Release versions have been returned by default. If you only want the PHP version, without the release, you can use the following command:<\/p>\n\n\n\n

    $ php -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION."\\n";'<\/code><\/pre>\n\n\n\n

    Which will return output similar to this:<\/p>\n\n\n\n

    8.0<\/code><\/pre>\n\n\n\n

    The above examples return the Cli PHP version. Your intention may be to return the version of the Apache module or PHP-FPM and not CLI. Depending on the settings the versions may be different.<\/p>\n\n\n\n

    Find the PHP Version Used When Using Apache or Nginx<\/p>\n\n\n\n

    We have two good ways of finding the PHP version when using a web server like Apache or Nginx.<\/p>\n\n\n\n

    1 Create a PHP (.php) file and add the following code:<\/strong><\/p>\n\n\n\n

    phpinfo();<\/code><\/pre>\n\n\n\n

    Save the file on your web directory and open it using a web browser. It will show the actual PHP version being used.<\/p>\n\n\n\n

    2 A Better Way.<\/strong><\/p>\n\n\n\n

    The above example may be too verbose or overkill. A simpler solution is to use this function instead.<\/p>\n\n\n\n

    echo php_ini_loaded_file().PHP_EOL;<\/code><\/pre>\n\n\n\n

    There you have it, you should be able to get the right PHP version.<\/p>\n","protected":false},"excerpt":{"rendered":"

    You can find the active major, minor, and release PHP version in Linux servers with simple commands. There are two simple solutions using the PHP command-line with additional parameters. 1….<\/p>\n","protected":false},"author":1,"featured_media":10739,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,23,9,27,16],"tags":[],"yoast_head":"\nHow to get Active Major, Minor, and Release PHP Version in Linux<\/title>\n<meta name=\"description\" content=\"Here we will show you how to find the active major, minor, and release PHP version in Linux and BSD server environments\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/local.brightwhiz\/get-active-major-minor-and-release-php-version-in-linux\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to get Active Major, Minor, and Release PHP Version in Linux\" \/>\n<meta property=\"og:description\" content=\"Here we will show you how to find the active major, minor, and release PHP version in Linux and BSD server environments\" \/>\n<meta property=\"og:url\" content=\"http:\/\/local.brightwhiz\/get-active-major-minor-and-release-php-version-in-linux\/\" \/>\n<meta property=\"og:site_name\" content=\"Brightwhiz.com\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/brightwhiz\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-11-07T18:54:18+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-12-03T13:28:28+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/local.brightwhiz\/wp-content\/uploads\/2021\/11\/PHP-Version.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Michael Bright\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@brightwhizmag\" \/>\n<meta name=\"twitter:site\" content=\"@brightwhizmag\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Michael Bright\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"http:\/\/local.brightwhiz\/get-active-major-minor-and-release-php-version-in-linux\/#article\",\"isPartOf\":{\"@id\":\"http:\/\/local.brightwhiz\/get-active-major-minor-and-release-php-version-in-linux\/\"},\"author\":{\"name\":\"Michael Bright\",\"@id\":\"http:\/\/local.brightwhiz\/#\/schema\/person\/81f0f3126f13834ae2e7f381b3028e32\"},\"headline\":\"How to get Active Major, Minor, and Release PHP Version in Linux\",\"datePublished\":\"2021-11-07T18:54:18+00:00\",\"dateModified\":\"2021-12-03T13:28:28+00:00\",\"mainEntityOfPage\":{\"@id\":\"http:\/\/local.brightwhiz\/get-active-major-minor-and-release-php-version-in-linux\/\"},\"wordCount\":274,\"commentCount\":0,\"publisher\":{\"@id\":\"http:\/\/local.brightwhiz\/#organization\"},\"image\":{\"@id\":\"http:\/\/local.brightwhiz\/get-active-major-minor-and-release-php-version-in-linux\/#primaryimage\"},\"thumbnailUrl\":\"http:\/\/local.brightwhiz\/wp-content\/uploads\/2021\/11\/PHP-Version.jpg\",\"articleSection\":[\"Articles\",\"Guides\",\"How To\",\"Programming\",\"Technology\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"http:\/\/local.brightwhiz\/get-active-major-minor-and-release-php-version-in-linux\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"http:\/\/local.brightwhiz\/get-active-major-minor-and-release-php-version-in-linux\/\",\"url\":\"http:\/\/local.brightwhiz\/get-active-major-minor-and-release-php-version-in-linux\/\",\"name\":\"How to get Active Major, Minor, and Release PHP Version in Linux\",\"isPartOf\":{\"@id\":\"http:\/\/local.brightwhiz\/#website\"},\"primaryImageOfPage\":{\"@id\":\"http:\/\/local.brightwhiz\/get-active-major-minor-and-release-php-version-in-linux\/#primaryimage\"},\"image\":{\"@id\":\"http:\/\/local.brightwhiz\/get-active-major-minor-and-release-php-version-in-linux\/#primaryimage\"},\"thumbnailUrl\":\"http:\/\/local.brightwhiz\/wp-content\/uploads\/2021\/11\/PHP-Version.jpg\",\"datePublished\":\"2021-11-07T18:54:18+00:00\",\"dateModified\":\"2021-12-03T13:28:28+00:00\",\"description\":\"Here we will show you how to find the active major, minor, and release PHP version in Linux and BSD server environments\",\"breadcrumb\":{\"@id\":\"http:\/\/local.brightwhiz\/get-active-major-minor-and-release-php-version-in-linux\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/local.brightwhiz\/get-active-major-minor-and-release-php-version-in-linux\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/local.brightwhiz\/get-active-major-minor-and-release-php-version-in-linux\/#primaryimage\",\"url\":\"http:\/\/local.brightwhiz\/wp-content\/uploads\/2021\/11\/PHP-Version.jpg\",\"contentUrl\":\"http:\/\/local.brightwhiz\/wp-content\/uploads\/2021\/11\/PHP-Version.jpg\",\"width\":1200,\"height\":630,\"caption\":\"release PHP Version\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/local.brightwhiz\/get-active-major-minor-and-release-php-version-in-linux\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/local.brightwhiz\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to get Active Major, Minor, and Release PHP Version in Linux\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/local.brightwhiz\/#website\",\"url\":\"http:\/\/local.brightwhiz\/\",\"name\":\"Brightwhiz.com\",\"description\":\"Best Tech guides, Tutorials, and News\",\"publisher\":{\"@id\":\"http:\/\/local.brightwhiz\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/local.brightwhiz\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"http:\/\/local.brightwhiz\/#organization\",\"name\":\"Brightwhiz\",\"url\":\"http:\/\/local.brightwhiz\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/local.brightwhiz\/#\/schema\/logo\/image\/\",\"url\":\"http:\/\/local.brightwhiz\/wp-content\/uploads\/2021\/11\/brightwhiz-com-logo-orange.png\",\"contentUrl\":\"http:\/\/local.brightwhiz\/wp-content\/uploads\/2021\/11\/brightwhiz-com-logo-orange.png\",\"width\":706,\"height\":135,\"caption\":\"Brightwhiz\"},\"image\":{\"@id\":\"http:\/\/local.brightwhiz\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/brightwhiz\/\",\"https:\/\/x.com\/brightwhizmag\",\"https:\/\/instagram.com\/bright_whiz\/\",\"https:\/\/www.pinterest.com\/sobbayi\/\",\"https:\/\/www.youtube.com\/channel\/UC6sCdP_d_RiTIM7ErFT-PSQ\"]},{\"@type\":\"Person\",\"@id\":\"http:\/\/local.brightwhiz\/#\/schema\/person\/81f0f3126f13834ae2e7f381b3028e32\",\"name\":\"Michael Bright\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/local.brightwhiz\/#\/schema\/person\/image\/\",\"url\":\"http:\/\/1.gravatar.com\/avatar\/da90485875ff0aafa38fdd494abe87d1?s=96&d=mm&r=g\",\"contentUrl\":\"http:\/\/1.gravatar.com\/avatar\/da90485875ff0aafa38fdd494abe87d1?s=96&d=mm&r=g\",\"caption\":\"Michael Bright\"},\"sameAs\":[\"https:\/\/sobbayi.com\"],\"url\":\"http:\/\/local.brightwhiz\/author\/sobbayiadmin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to get Active Major, Minor, and Release PHP Version in Linux","description":"Here we will show you how to find the active major, minor, and release PHP version in Linux and BSD server environments","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/local.brightwhiz\/get-active-major-minor-and-release-php-version-in-linux\/","og_locale":"en_US","og_type":"article","og_title":"How to get Active Major, Minor, and Release PHP Version in Linux","og_description":"Here we will show you how to find the active major, minor, and release PHP version in Linux and BSD server environments","og_url":"http:\/\/local.brightwhiz\/get-active-major-minor-and-release-php-version-in-linux\/","og_site_name":"Brightwhiz.com","article_publisher":"https:\/\/www.facebook.com\/brightwhiz\/","article_published_time":"2021-11-07T18:54:18+00:00","article_modified_time":"2021-12-03T13:28:28+00:00","og_image":[{"width":1200,"height":630,"url":"http:\/\/local.brightwhiz\/wp-content\/uploads\/2021\/11\/PHP-Version.jpg","type":"image\/jpeg"}],"author":"Michael Bright","twitter_card":"summary_large_image","twitter_creator":"@brightwhizmag","twitter_site":"@brightwhizmag","twitter_misc":{"Written by":"Michael Bright","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"http:\/\/local.brightwhiz\/get-active-major-minor-and-release-php-version-in-linux\/#article","isPartOf":{"@id":"http:\/\/local.brightwhiz\/get-active-major-minor-and-release-php-version-in-linux\/"},"author":{"name":"Michael Bright","@id":"http:\/\/local.brightwhiz\/#\/schema\/person\/81f0f3126f13834ae2e7f381b3028e32"},"headline":"How to get Active Major, Minor, and Release PHP Version in Linux","datePublished":"2021-11-07T18:54:18+00:00","dateModified":"2021-12-03T13:28:28+00:00","mainEntityOfPage":{"@id":"http:\/\/local.brightwhiz\/get-active-major-minor-and-release-php-version-in-linux\/"},"wordCount":274,"commentCount":0,"publisher":{"@id":"http:\/\/local.brightwhiz\/#organization"},"image":{"@id":"http:\/\/local.brightwhiz\/get-active-major-minor-and-release-php-version-in-linux\/#primaryimage"},"thumbnailUrl":"http:\/\/local.brightwhiz\/wp-content\/uploads\/2021\/11\/PHP-Version.jpg","articleSection":["Articles","Guides","How To","Programming","Technology"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["http:\/\/local.brightwhiz\/get-active-major-minor-and-release-php-version-in-linux\/#respond"]}]},{"@type":"WebPage","@id":"http:\/\/local.brightwhiz\/get-active-major-minor-and-release-php-version-in-linux\/","url":"http:\/\/local.brightwhiz\/get-active-major-minor-and-release-php-version-in-linux\/","name":"How to get Active Major, Minor, and Release PHP Version in Linux","isPartOf":{"@id":"http:\/\/local.brightwhiz\/#website"},"primaryImageOfPage":{"@id":"http:\/\/local.brightwhiz\/get-active-major-minor-and-release-php-version-in-linux\/#primaryimage"},"image":{"@id":"http:\/\/local.brightwhiz\/get-active-major-minor-and-release-php-version-in-linux\/#primaryimage"},"thumbnailUrl":"http:\/\/local.brightwhiz\/wp-content\/uploads\/2021\/11\/PHP-Version.jpg","datePublished":"2021-11-07T18:54:18+00:00","dateModified":"2021-12-03T13:28:28+00:00","description":"Here we will show you how to find the active major, minor, and release PHP version in Linux and BSD server environments","breadcrumb":{"@id":"http:\/\/local.brightwhiz\/get-active-major-minor-and-release-php-version-in-linux\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/local.brightwhiz\/get-active-major-minor-and-release-php-version-in-linux\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/local.brightwhiz\/get-active-major-minor-and-release-php-version-in-linux\/#primaryimage","url":"http:\/\/local.brightwhiz\/wp-content\/uploads\/2021\/11\/PHP-Version.jpg","contentUrl":"http:\/\/local.brightwhiz\/wp-content\/uploads\/2021\/11\/PHP-Version.jpg","width":1200,"height":630,"caption":"release PHP Version"},{"@type":"BreadcrumbList","@id":"http:\/\/local.brightwhiz\/get-active-major-minor-and-release-php-version-in-linux\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/local.brightwhiz\/"},{"@type":"ListItem","position":2,"name":"How to get Active Major, Minor, and Release PHP Version in Linux"}]},{"@type":"WebSite","@id":"http:\/\/local.brightwhiz\/#website","url":"http:\/\/local.brightwhiz\/","name":"Brightwhiz.com","description":"Best Tech guides, Tutorials, and News","publisher":{"@id":"http:\/\/local.brightwhiz\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/local.brightwhiz\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"http:\/\/local.brightwhiz\/#organization","name":"Brightwhiz","url":"http:\/\/local.brightwhiz\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/local.brightwhiz\/#\/schema\/logo\/image\/","url":"http:\/\/local.brightwhiz\/wp-content\/uploads\/2021\/11\/brightwhiz-com-logo-orange.png","contentUrl":"http:\/\/local.brightwhiz\/wp-content\/uploads\/2021\/11\/brightwhiz-com-logo-orange.png","width":706,"height":135,"caption":"Brightwhiz"},"image":{"@id":"http:\/\/local.brightwhiz\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/brightwhiz\/","https:\/\/x.com\/brightwhizmag","https:\/\/instagram.com\/bright_whiz\/","https:\/\/www.pinterest.com\/sobbayi\/","https:\/\/www.youtube.com\/channel\/UC6sCdP_d_RiTIM7ErFT-PSQ"]},{"@type":"Person","@id":"http:\/\/local.brightwhiz\/#\/schema\/person\/81f0f3126f13834ae2e7f381b3028e32","name":"Michael Bright","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/local.brightwhiz\/#\/schema\/person\/image\/","url":"http:\/\/1.gravatar.com\/avatar\/da90485875ff0aafa38fdd494abe87d1?s=96&d=mm&r=g","contentUrl":"http:\/\/1.gravatar.com\/avatar\/da90485875ff0aafa38fdd494abe87d1?s=96&d=mm&r=g","caption":"Michael Bright"},"sameAs":["https:\/\/sobbayi.com"],"url":"http:\/\/local.brightwhiz\/author\/sobbayiadmin\/"}]}},"_links":{"self":[{"href":"http:\/\/local.brightwhiz\/wp-json\/wp\/v2\/posts\/9841"}],"collection":[{"href":"http:\/\/local.brightwhiz\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/local.brightwhiz\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/local.brightwhiz\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/local.brightwhiz\/wp-json\/wp\/v2\/comments?post=9841"}],"version-history":[{"count":0,"href":"http:\/\/local.brightwhiz\/wp-json\/wp\/v2\/posts\/9841\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/local.brightwhiz\/wp-json\/wp\/v2\/media\/10739"}],"wp:attachment":[{"href":"http:\/\/local.brightwhiz\/wp-json\/wp\/v2\/media?parent=9841"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/local.brightwhiz\/wp-json\/wp\/v2\/categories?post=9841"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/local.brightwhiz\/wp-json\/wp\/v2\/tags?post=9841"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}