B2GraphiX B2GraphiX - 10 months ago 56
PHP Question

Get the web server version in php

I would like the version of a web server (Nginx, MySQL, MariaDB, ...) in PHP.

I know the function for Apache:

There are many
which returns all values but how to exploit?

You would have an idea or it is not possible for the moment?


A simple shell_exec would do the trick (assuming you're on a unix based server). Just don't put any user data into the command, and be aware that this approach may not work in shared hosting environments:

$nginxVersion = shell_exec('nginx -v 2>&1');
$mysqlVersion = shell_exec('mysql --version');

Note that nginx sends version output to stderr, so you need to pipe it to stdout to capture it.