php script to find web server name

apache, nginx, php, varnish, webserver

Solution

You can get the server information using `$_SERVER` method in php.

`$_SERVER['SERVER_SOFTWARE']` returns name like Apache/2.2.21 (Win32) PHP/5.3.10

Problem

Is there any php script to find the name of the web server like apache, varnish, nginx, etc. I know about netcraft and wappalyzer, but I want to have a script to run in my local machine The main reason is, I have 4 servers in my local machine Apache2, nginx, Varnish and Lighty. I have different ports for them like localhost:70 localhost:7070 etc. But all the servers root folder is /var/www/ and I have one index.php in /www which lists all the projects under /www folder. I need some php script to echo the server name to insert in my index.php file, eg: if I use localhost:70 the script would detect its Apache and will display Apache, so on.

Original source