How to deploy a PHP app to Heroku

1. Download and install Heroku Toolbelt:

2. Install Heroku Push (because port 22 is blocked by University’s firewall)

heroku plugins:install

1. Create an empty project and Git Repository

mkdir heroku-php
cd heroku-php
git init

2. Commit to Git

Place the PHP files in the created directory

Now add to git:

git add -A

Now commit:

git commit -m "Initial commit"

3. Create your Heroku app

This is the important step. When creating a PHP app on heroku you have to make sure you choose the ‘Cedar’ Stack.

heroku create --stack cedar

The response should look something like:

Creating damp-wildwood-1022... done, stack is cedar |
Git remote heroku added

Now push to the repository:

heroku push

The response should now look a little like:

Checking for app files to sync... done, 1 files needed
Uploading: 100.0%
Launching build process... done
Preparing app for compilation... done
Fetching buildpack... done
Detecting buildpack... done, Buildkit+PHP
Fetching cache... done
Compiling app...
  Compiling for PHP
  Bundling Apache version 2.2.22
  Bundling PHP version 5.3.10
Putting cache... done
Creating slug... done
Uploading slug... done
Success, slug is
Releasing to damp-wildwood-1022... ....done, v11

Test! You’re done

Notice Heroku gives you an auto generated app name. If you look in the first response in step 3, Heroku tells you the URL of your app. Mine is

Now you would definitely want your app name to look tidy. Do this:

heroku apps:rename newname

Once you are done editing all the project files,

heroku open

should take you to your app on a web browser.

Published by Shibu Lijack

Frontend Web Developer | Music Enthusiast | Foodie | Technophile

Leave a comment

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: