First I know this variable : _SERVER["SERVER_SOFTWARE"]

In one of my application, I want to check from PHP script which webserver it is running on. Basically it will be a wordpress plugin which will help Bloggers tweak some configure.

I have created separate process for Apache & Nginx and was also thinking about releasing code as 2 different wordpress plugins.

Then I just got curious to know if there is a FULLPROOF way in PHP to detect webservers flawlessly.

Please consider all cases :: Apache, Nginx, Apache + Nginx, PHP as Apache module, PHP using fastcgi, php-fpm, lighttpd, IIS, etc.

Also its critical for my application to detect combos and proxies presence.



closed as off-topic by Michael Hampton Apr 12 '18 at 16:59

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions on Server Fault must be about managing information technology systems in a business environment. Home and end-user computing questions may be asked on Super User, and questions about development, testing and development tools may be asked on Stack Overflow." – Michael Hampton
If this question can be reworded to fit the rules in the help center, please edit the question.


Short answer is that its impossible to deterministically identify what webserver is in use. The closest you'll get is the value of $_SERVER["SERVER_SOFTWARE"].

It is possible to get a fairly good idea what software is running at a [particular URL by application fingerprinting but that's very very complicated - and it'll only tell you what's terminating the HTTP connection - it may be a proxy.

What you see in phpinfo() will not show the web server for [fast]cgi and it'll only show what the adminstrator chooses to make available on other systems.

Also its critical for my application to detect combos and proxies presence.

I have no idea what you mean by 'combos'. As for proxies....there is no way to tell that either.

Perhaps if you explained why you need this information and what value it has to you then we might be able to make a more informed guess as to an answer which might suit your needs.


  • By cambo I simply mean - some users choose Nginx as front-end web server and then use Apache to run PHP. One case is that they want to run cpanel and nginx together. Now in my application, in one section, I want to guide users for some complex rewrite rule based on webserver. In above apache+nginx case, which web-server my PHP script will detect? I – rahul286 Jul 28 '10 at 15:15

Someone on the PHP Manual site posted a way to get phpinfo() variables into an array, there's lots of information there but also the System where php is running, maybe you can use that. Look at the comments.

Also, detecting proxies is not that easy, you can use http headers (like Via) but there're a lot of ways that it can go wrong.

  • thanks for your answer and help. I know via headers cannot be trusted and that is the reason I am seeking some help. – rahul286 Jul 28 '10 at 15:16

Not the answer you're looking for? Browse other questions tagged or ask your own question.