My web server uses PHP as do 77.7% of web servers according to W3Techs, as of 14/03/2022.

The reason I use PHP is an inertia born out of seeing everyone else using it on web servers. What is it about PHP that would make it so ubiquitous on web servers?

(Note that this question is similar to the following question but takes it in a different direction: Why isn't Java used for modern web application development?)

  • 5
    I always assumed because it is easy to install on Apache and nearly all web servers are Apache.
    – maple_shaft
    Commented Sep 26, 2011 at 18:03
  • 16
    PHP is the language that proves that while nearly everybody can program, nearly all of them shouldn't. It's the Visual Basic of the web generation. Commented Sep 27, 2011 at 13:56
  • 3
    I want to argue another point - PHP has good abstractions for websites - it's cache friendly, it has an immutable request/response cycle, it doesn't make you deal with resource management, it doesn't make you deal with data structures, its dynamic nature works well with databases and it has a ton of built in functions so packages are more rare and deployment is easy. I don't like PHP, but it's very easy to make a case for it - I'm not convinced but it's easy to make. Commented Dec 10, 2015 at 11:53

6 Answers 6


PHP is a language specifically designed for web development with built-in support for MySQL, the most popular open source database.

  • Easy to start with: As a beginner it is easy to start with PHP. The user just has to add a few PHP-tags in their existing HTML files and upload it to the server and see the result. Dynamic typing and associative arrays also make it easier to start using PHP.

  • Easy to use: Compared to other solutions like Java, PHP doesn't need to be compiled, so you just need to write the script and upload it to the server.

  • Integrated database support: PHP has built-in support for some of the most popular databases such as MySQL, PostgreSQL, SQLite, Microsoft SQL Server, IBM, and Oracle. That means it is easy to start using databases as no additional drivers need to be installed. The easy-to-use web-based admin tool PHPMyAdmin (released in 1998) is also a significant reason for PHP's success.

  • Old language with a big user base: PHP became popular early (in 1995) since it was designed for web development. Since then, the user base has grown and now there are many PHP frameworks and libraries, such as WordPress, Woocommerce, Magento, MediaWiki (which powers Wikipedia), Laravel, Bagisto, and Statamic.

  • Cheap hosting: Since PHP has existed for long time and works well on both Linux and Windows, many web servers support it. There is no problem finding hosting services with PHP pre-installed.


For the same reason MySQL is so popular: it was at the right place in the right time.

With the Linux server boom in the 90's, the LAMP platform (Linux-Apache-MySQL-PHP) came to scene as a reliable and, most importantly, free option.

As a side note, take MySQL at the time. These were two missing features from MySQL (from the top of my mind, there might be more) not so long ago:

  • No triggers
  • Not fully ACID compliant

How did a DB that wasn't even ACID (atomicity-consistency-isolation-durability) compliant get to be so popular? Same answer as PHP: it was at the right place in the right time.

Further reading about the "right place right time" on LAMP components:

  • 3
    If "it was at the right place in the right time" is the answer, then Perl and CGI with C should have seen the same popularity.
    – Jonas
    Commented Sep 26, 2011 at 20:12
  • 2
    "How did a DB that wasn't even ACID compliant get to be so popular?" - thats easy... its just wasnt that important to most people. MySQL was reliable enough for most web uses. Reliable enough early on for a bank? Probably not. For a web forum? Yes. Commented Sep 26, 2011 at 20:45
  • I had a colleague the would scream "but MySQL is hardly a RDBMS!". I find that amusing. Popularity is a funny thing. We - software developers - must not be slaves of trend, we have to keep on learning to keep on working. Anyone who defends a tech too much is less likely to let go. And that's always professionally dangerous. This topic is over for me. :) Commented Sep 26, 2011 at 20:48

If you look around, most folks running PHP these days are running Wordpress, Drupal, Joomla and the like. Or one of 10,000 free, popular apps that pretty much work out of the box with a cheap PHP host and a little configuration. Many times it gets installed not because anyone is making something that runs on PHP so much as the easiest option is to use something built on PHP.


I'm teaching myself PHP right now, so maybe I can answer.

A PHP source code file can contain a mix of HTML, JavaScript and PHP, so it seems really easy to get simple web applications up and running. More complex interactions, that would require lots of Java in a JSP situation, or some weird contortions in a CGI-BIN situation, get catered to by the PHP builtins: you don't even have to know if an HTTP GET or POST called your code, everything your code wants to know lives in _REQUEST or _SERVER or _COOKIE global variables.

PHP-the-langauage gets parsed and executed pretty rapidly so you won't notice a huge performance drop when generating HTML, rather than just having a bunch of static HTML files.

PHP-the-interpreter has library calls for just about every open source DBMS, and a lot of the proprietary ones, too, so making a 3-tier-style web app looks easy. PHP-the-interpreter includes library calls for a lot of other commons situations (a.k.a. "use cases"), so you don't have to write a lot of code yourself, just call the library. So, just like J2EE "enterprise apps", the problem moves from knowing how to code to knowing how to look library stuff up. This is aided by the very decent php.net PHP manual.

As a programming language, PHP doesn't have a lot of exotic constructs, or differ too much from, say C, FORTRAN 4 or Pascal, so programmers that already know one language can easily pick up PHP-the-programming language.


There are two key points for PHP's success: The timing and the focus on shared hosting.

In the beginning the Web was static. Web-Servers could only distribute pre-generated HTML this obviously wasn't enough after some time so in 1993 the NCSA team extended their web server (the predecessor of Apache httpd) with a technology called CGI which allowed calling specific programs from the web server which could generated HTML (or other content) on the fly. This was great as people could do all the things. A commonly used language at that time for that purpose was Perl. Perl is a language strong in text processing which is a key property for handling HTTP request data and producing HTML. So people used it.

But there was a problem: For each and every request the web server had to run an external program, Perl had to initialize and run the script. This caused quite some headache. A solution was mod_perl coming ca. 1997. mod_perl is a module for the Apache webserver embedding the Perl interpreter directly into the web server process so no extra startup was need.

But again this approach had a problem: mod_perl was extremely powerful and had access to the complete server configuration. You couldn't use one server to host multiple independent clients as they could easily harm the other people - be it on purpose or by accident. And that's where PHP came.

PHP was built in a way that it could run as Apache module (thus not having the startup hit for each request) but provides a shared-nothing environment between requests. Once a request was done all information was lost and a subsequent request to another virtual host would be served independently. PHP also offered features to restrict access (safe_mode, open_base_dir). With that architectural choice companies could install PHP on their server and provide customers FTP (or similar) access to upload their files and by that host many many customers on a single machine without much work. This caused a competition leading to cheap prices for PHP-based hosting making PHP an ubiquitous platform.

Additionally PHP had a few benefits over Perl, like allowing to mix HTML and PHP code or direct access to request variables (see also register_globals) which in Perl was harder (custom parsing or dependency on CGI.pm) which developers liked.

Another aspect which made PHP successful in those days was good support on Windows. Getting Perl or other languages working on Windows was hard, but back at that time many developers where using Windows at home and virtualization or containers weren't a thing, yet. PHP did run easily on Windows so people could use it for development and then pack up the files and deploy on Linux. With Perl for instance you would have to get the correct perl distribution and then check which modules are available at all etc.

What about other languages? Compiled languages like C or C++ never got traction since scripting serves the rapid developing market better. Java existed, but Java Virtual machines required way more resources and shared hosting in the way PHP supports it was hardly doable. Investment in harddware was way higher. ASP (as predecessor of ASP.Net) was bound to the Windows platform, limiting it to organizations which already run Windows and who don't fear the licensing costs, and again no shared hosting support.

Different other technologies where produced but either were commercial (Cold Fusion or Netscape Server with server-side JavaScript) limiting their reach or didn't et out of their reach till Ruby-on-rails came, which probably was the first environment receiving lots of attention, but by that time PHP was already very popular with a large community and well-established software (like Wordpress or Drupal) making it hard to compete - especially as development of PHP never stopped and is still going on.


Lets face it, PHP is cheap, easy to learn, has a large community, you can host it anywhere, and it's been around a lot. So, if you think as someone using the internet as a way to make money fast in a small/medium industry and having to create a development area to do so with a practically nonexistent infrastructure, PHP sounds pretty great (to start with).

So I think PHP is a great way to make some money fast with a bunch of programmers and a small computer as a server.

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