Share your love
Find Apache and PHP Version Installed on Linux: 2 Easy Steps

If you don’t know which versions of Apache and PHP you have on your Linux server, you can easily Find Apache and PHP Version Installed on Linux by using the Linux Commands from the CLI. To do this, follow the rest of the article.
Table of Contents
Steps To Find Apache and PHP Version Installed on Linux
You can use the commands on all distributions. To Find Apache and PHP Version Installed on Linux, you must have SSH access to your Linux server as a root or non-root user with sudo privileges. To do this, you can visit the Orcacore website and check the Linux server’s initial guides.
Step 1 – Find the PHP Version in the Linux Command Line
The most common way to display the PHP version installed on your server is to use the php -v command. For example on my AlmaLinux server, I have the following PHP version installed:
php -vExample Output
PHP 8.2.11 (cli) (built: Sep 26 2023 11:11:58) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.2.11, Copyright (c) Zend TechnologiesOr you can use the command below:
php --versionIt will show you the same results.
To get more information about your PHP on your server, you can use the php -i command:
php -i
Step 2 – Find the Apache Version in the Linux Command Line
At this point, you can easily find your Apache version from CLI based on your Linux distros.
Apache Version in RHEL Linux
In the RHEL-based distros, the Apache package is named httpd. To find your Apache version on Centos, AlmaLinux, and Rocky Linux, you can use the httpd -v command. For example, in my Centos server, I have the following HTTPD service:
httpd -vExample Output
Server version: Apache/2.4.6 (CentOS)
Server built:   May 30 2023 14:01:11Also, you can print the version and build parameters of httpd in RHEL-based distros by using the -V option:
httpd -VExample Output
Server version: Apache/2.4.6 (CentOS)
Server built:   May 30 2023 14:01:11
Server's Module Magic Number: 20120211:24
Server loaded:  APR 1.4.8, APR-UTIL 1.5.2
Compiled using: APR 1.4.8, APR-UTIL 1.5.2
Architecture:   64-bit
Server MPM:     prefork
  threaded:     no
    forked:     yes (variable process count)
Server compiled with....
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=256
 -D HTTPD_ROOT="/etc/httpd"
 -D SUEXEC_BIN="/usr/sbin/suexec"
 -D DEFAULT_PIDLOG="/run/httpd/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="conf/mime.types"
 -D SERVER_CONFIG_FILE="conf/httpd.conf"To get more information about HTTPD service, you can use the command below:
# dnf info httpd
# yum info httpdApache Version in Debian and Ubuntu Linux
In the Debian-based distros, the Apache package is named apache2. To get the Apache version on Debian-based distros like Ubuntu 22.04, and Debian 12, you can use the apache2 -v command. For example:
apache2 -vExample Output
Server version: Apache/2.4.52 (Ubuntu)
Server built:   2023-05-03T20:02:51
To get more information about the apache2 service, you can use the command below:
apt info apache2Example Output
Package: apache2
Version: 2.4.52-1ubuntu4.6
Priority: optional
Section: web
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Debian Apache Maintainers <debian-apache@lists.debian.org>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 546 kB
Provides: httpd, httpd-cgi
Pre-Depends: init-system-helpers (>= 1.54~)
Depends: apache2-bin (= 2.4.52-1ubuntu4.6), apache2-data (= 2.4.52-1ubuntu4.6), apache2-utils (= 2.4.52-1ubuntu4.6), lsb-base, mime-support, perl:any, procps
Recommends: ssl-cert
Suggests: apache2-doc, apache2-suexec-pristine | apache2-suexec-custom, www-browser, ufw
Conflicts: apache2.2-bin, apache2.2-common
Replaces: apache2.2-bin, apache2.2-common
Homepage: https://httpd.apache.org/
Task: lamp-server
Download-Size: 97.8 kB
APT-Manual-Installed: yes
APT-Sources: http://de.archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages
...That’s it, you are done.
Conclusion
At this point, you have learned to Find Apache and PHP Version Installed on Linux distributions by using the Linux Commands. Also, you may like these articles:
Check if PHP is Working on Apache in Ubuntu
 
	


Thanks for the trick
you’re welcome
We are glad that our guide was useful for you