Blog Logo
  • Home
  • About

Want Heroku Apache (PHP), but getting Node.js stack?

by Drew Engelson — 29 Aug 2013

I've been using Heroku to host a bunch of static sites using the Apache/PHP hack. All I need is an index.php file in the root of my application to hint to Heroku that I want the PHP (Apache) buildpack... and then I disable PHP altogether since I really just want Apache to serve a static site. But some of my recent attempts at creating these stacks have results in Heroku giving me a Node.js stack instead... WTF?!?

Turns out that some of the newer node-based tools for managing static assets require a "package.json" file, which makes Heroku think you want a Node.js stack.

Quick solution

Specify the buildpack when creating the app.

$ heroku create myapp --buildpack https://github.com/heroku/heroku-buildpack-php

Or specify the buildpack as a config parameter.

$ heroku create myapp
$ heroku config:set BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-php

This will force Heroku to use the buildpack you want.

With the rapid evolution of front end tools for managing your Javascript and CSS assets, we're seeing Node-based tools crop up all over the place... In fact, Node Package Manager (npm) is quickly becoming the de facto standard for installing most new web tools. This is a great thing, however, we're really beginning to blur the lines between front and back end technologies. Since Heroku attempts to introspect an app to determine which stack to create, the existence of package.json creates confusion. And because the PHP stack even isn't officially supported, the Node stack wins. We just need to be more explicit these days.

Drew Engelson
Author

Drew Engelson

https://tomatohater.com

I currently lead the Cloud Foundation Services team at Starbucks. We are building the Starbucks PaaS to allow digital platforms to be deployed globally with a focus on automation, scalability, performance, security, and developer experience.

Prior to Starbucks, I led Celerity's Technology Innovation and Architecture practice and founded Zoombit and served in technology leadership at Huge and PBS.

Yes. I seriously hate tomatoes.

All content copyright Tomatohater © 2006-2021 • All rights reserved.
0.06g of CO2/viewWebsite Carbon
 Cleaner than 95% of pages tested