Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.



share|improve this 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.


share|improve this answer
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.

share|improve this answer
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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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