It’s because PHP’s popularity is old and Postgres used to be mid. MySQL was faster and better than Postgres.
But Postgres slowly improved and then got better than MySQL while MySQL stagnated. The most basic bugs persisted, basic features never got added and consistency never seemed to be a point of improvement.
Not sure about Apache, but Linux, MySQL and PHP is still the most common combo in terms of number of sites running it. Wordpress alone is enough to establish that.
js is more associated with Mongo, another bad db. Most modern js projects (or any modern project really, except PHP) use Postgres