PHP script to find the name of the web server
Is there any php script to find the name of the webserver like apache, varnish, nginx, etc.
I know about netcraft and wappalyzer, but I want the script to run on my local machine
The main reason is that I have 4 servers on my local machine Apache2, nginx, Varnish and Lighty.
I have different ports for them like localhost: 70 localhost: 7070 etc. But all server root folders are / var / www / and I have one index.php in / www which lists all projects in / www folder.
I need a little php script to echo the server name to insert into my index.php file, for example: if I use localhost: 70 the script will detect it Apache and display Apache, etc.
Use a superglobal $_SERVER
with an index SERVER_SOFTWARE
:
$serverSoftware = $_SERVER['SERVER_SOFTWARE'];
The above code gives the fully qualified name of the server software. If you only want to get the name of the webserver use this way:
$webServerName = explode('/', $serverSoftware)[0];
Note: The $ _SERVER index is case sensitive. SERVER_SOFTWARE
doesn't work (as i tried before).
source to share
Wappalyzer has a PHP port that can be run from the command line or PHP script:
https://github.com/ElbertF/Wappalyzer#drivers
https://github.com/ElbertF/Wappalyzer/tree/master/drivers/php
source to share