top of page
vgfd-Edited-Final (1).jpg

How to Deploy Your PHP App on Heroku Cloud Platform for Free

Heroku is one of the most popular cloud platform as a service (PAAS). It was one of the first cloud platforms, and has been around since 2007. It is popular due to its support for variety of languages, including Ruby, Python, Java, Node.js, Scala and PHP. And also because it allows you to pay only for the resources that you use and offers database as a service along with several advanced addons for flexibility.

In this tutorial, we’ll be deploying a simple PHP app, that we’ll deploy on Heroku using the toolbelt. To get started with this, you will need to create an account on Heroku. Don’t worry, its free to create an account on Heroku here.

Once you’ve signed up, successfully, you will need to install the Heroku Toolbelt. (Heroku has well documented the installation procedure for the toolbelt on same page). Once the toolbelt is installed, you need to log in using your email and password (i.e. your Heroku log in credentials).

In this tutorial, we’ve used Ubuntu OS, along with Terminal. But you can install Heroku toolbelt on Windows as well Mac OS X. Login using this command:

[html] $ heroku login [/html]

It will prompt you to enter your email and password.

Once you have logged in successfully. You will get a message “Authentication successful”.

Now you need to upload your SSH keys on Heroku.

For generating SSH keys use command:

[html] $ ssh-keygen -t rsa [/html]

This should generate public/private SSH keypair. Now adding your SSH keys to Heroku:

[html] $ heroku keys:add [/html]

Now you’ve successfully setup the Heroku toolbelt on your machine.

Demo: Deploying PHP app on Heroku

In this demo, we will create a simple PHP app, that will print phpinfo(); here is the code for index.php

[php] <?php echo “hello world”; phpinfo(); ?> [/php]

Save this file in a new folder ‘myapp’. Using cmd, `cd` to the new folder.

[html] $ mkdir myapp $ cd myapp [/html]

Please make sure, you’ve added the ‘index.php’ in the ‘myapp’ folder..

Now you need to initialize git in this new folder, using:

[html] $ git init [/html]

Now once, the folder in initialized, you need to commit the repo:

[html] $ git add . $ git commit -m “Initial” [/html]

Now you need to create a Heroku app, and upload your app to Heroku using these commands:

[html] $ heroku create [/html]

This will create a Heroku app and will output the URL of your new Heroku app.

Now you can upload your app to Heroku using:

[html] $ git push heroku master [/html]

This will detect the ‘index.php’ file created and will create an instance bundled with Apache server. It will output the URL of the app. And you’ve successfully deployed your PHP app on Heroku. The demo app, created in this tutorial is accessible at

You can host full fledged websites on Heroku.


bottom of page