Find Apache and PHP Version Installed on Linux

If you don’t know which versions of Apache and PHP you have on your Linux server, you can easily find the Apache and PHP Version Installed by using the Linux Commands from the CLI. To do this, follow the rest of the article.

Steps To Find Apache and PHP Version Installed on Linux

You can use the commands on all distributions. To complete this guide, 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 -v
Example 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 Technologies

Or you can use the command below:

php --version

It 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
Example Output
phpinfo()
PHP Version => 8.2.11

System => Linux 5.10.0-1160.42.2.el8.x86_64 #1 SMP Tue Sep 7 14:49:57 UTC 2021 x86_64
Build Date => Sep 26 2023 11:11:58
Build System => Red Hat Enterprise Linux Server release 8.
Build Provider => Remi's RPM repository <https://rpms.remirepo.net/> #StandWithUkraine
Compiler => gcc (GCC) 10.2.1 20210130 (Red Hat 10.2.1-11)
Architecture => x86_64
Server API => Command Line Interface
Virtual Directory Support => disabled
Configuration File (php.ini) Path => /etc
Loaded Configuration File => /etc/php.ini
Scan this dir for additional .ini files => /etc/php.d
...

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 -v
Example Output
Server version: Apache/2.4.6 (CentOS)
Server built:   May 30 2023 14:01:11

Also, you can print the version and build parameters of httpd in RHEL-based distros by using the -V option:

httpd -V
Example 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 httpd

Apache 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 -v
Example 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 apache2
Example Output
Package: apache2
Version: 2.4.52-1ubuntu4.6
Priority: optional
Section: web
Origin: Ubuntu
Maintainer: Ubuntu Developers <[email protected]>
Original-Maintainer: Debian Apache Maintainers <[email protected]>
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

Upgrade PHP Version on AlmaLinux 8 and Rocky Linux 8

Install PHP with Apache and Nginx on Debian 12

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!