Deploying your PHP app to Heroku

You have started learning web designing and development. You have designed your first web app. Voila! But contrary to mobile apps, you need to host your web app on some server so that you can show off your impressive web app to others. Shelling out $5 a month on shared hosting for your first app doesn’t sound like a good idea. Enter Heroku!

Heroku is a PaaS, and if my memory serves me right, it may be the first PaaS offering too. For your first PHP app, Heroku may sound like a good option. With 512MB of RAM, 2TB bandwidth/month, and plenty more features, you wont have to think beyond Heroku. But even though most of its features are documented, you probably shall find less support for PHP from the open source community.

Though deploying your first PHP app on Heroku may sounds like child’s play, activating most of the features like gzip, caching static assets, setting expiry headers are quite a herculean task for someone quite inexperienced in this field. For someone well versed in Linux, git and compiling Apache and PHP from source, Heroku shall present itself as the best hosting option.

  1. Signup for a Heroku account
  2. Download and install Heroku Toolbelt. Git is already bundled along with it.
  3. Open up your command prompt, and navigate to your app folder using the cd command
  4. Login to Heroku, using heroku login. Enter your email address and password, and you shall be authenticated. Once you login, you need to create a ssh key.
  5. Once you complete that, type git init. It shall initialize your app folder with an empty git repo.
  6. Type git add .
  7. Type heroku create appname. Change appname to any name of your choice. If you want some random name, use the command heroku create
  8. Type git commit -m “Initial commit”
  9. Type git push heroku master

If you dont have an index.php file, it shall give an error. So better have an index.php in the root. With that, you have deployed your first PHP app!