I am curious to know the reason that makes PHP not capable to act as a application server. Node has its own http server and for Python I know that they have couple of http servers based on their WSGI.

PHP also has a development server, but why no one use in production.

  • 2
    What makes you think PHP is not capable to act as application server? May 1 '18 at 18:39
  • it does, php -S and also -t, php.net/manual/en/features.commandline.webserver.php
    – Uberfuzzy
    May 1 '18 at 18:53
  • @JörgWMittag php.net/manual/en/features.commandline.webserver.php this
    – user212699
    May 1 '18 at 19:03
  • So, because there is a warning against using one particular webserver in production that was never designed to be used in production in the first place, you conclude that it is fundamentally impossible to ever write a webserver that could possibly used in production? That is quite a leap. In Ruby, for example, the webserver that is shipped in the standard library is also not supposed to be used in production, but there are about 20 others that can be used in production. May 4 '18 at 15:45

The reason is historical.


PHP was born to provide a simple way to create dynamic web pages. In 1994, this would mean either:

  1. Implement your own server, which means spending months doing tedious and complex work,
  2. Or use CGI and rely on an existent web server with CGI support, such as NCSA httpd.

It is not surprising that, given the original goal of PHP, Rasmus Lerdorf decided to go with the second option, which led PHP to be compatible with the successor of NCSA httpd—Apache. Since then, PHP remains Apache-friendly, as much as LAMP stack is among the easiest things to set up for a beginner programmer.

PHP was always a language, and nothing more. It is not a web server, and wasn't intended to be a web server; instead, it relies on a web server as its primary execution vector.


Things were very different for Node.js. In 2009, Node.js was born as a reaction to the existent servers, including Apache:

Dahl criticized the limited possibilities of the most popular web server in 2009, Apache HTTP Server, to handle a lot of concurrent connections (up to 10,000 and more) and the most common way of creating code (sequential programming), when code either blocked the entire process or implied multiple execution stacks in the case of simultaneous connections.

Source: Wikipedia.

In this context, one would hardly make Node.js rely on Apache server (or IIS, or whatever). The processing model of Node.js is substantially different, which makes it impossible to integrate with WSGI or CGI.

If PHP is a language, Node.js is not. Node.js is a runtime environment which allows to run JavaScript outside the context of a browser. This makes Apache a competitor of Node.js. Does it surprise you that IIS doesn't need Apache to run?


Python is very like PHP. The SimpleHTTPServer you mention in your question is not intended to be used in production, so you end up hosting your application in either Gunicorn or Apache (or another server, depending on your preferences), exactly like you do with PHP.

Same logic here: writing a complete HTTP server is not an easy task, and also quite unnecessary: since most system administrators are familiar with Apache, why creating something new, when you can simply make Python WSGI-compatible?


Writing a webserver that just about works is easy.

Writing a webserver that performs well, is secure, is reliable and is able to run multiple requests in paralell is much harder.

In my experience, it is rare to see any of these built-in webservers used for public websites.

  • Same thing for Ruby as well. There is a simple web server that developers can use to get up and running quickly, but you would be laughed right off this planet if you ran your app that way in production. Use the right tool for the job. May 1 '18 at 19:24
  • 1
    You're missing the point of the question. If PHP uses Apache because “writing a real web server is hard,” then, following your logic, Node.js should use Apache as well. I won't downvote because I also posted an answer; nevertheless, yours is a non-answer. May 2 '18 at 17:54
  • Feel free to downvote, your answer is much better. May 2 '18 at 18:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy