Deploy your Laravel 4 application on Heroku

Heroku is a popular PaaS that allows you to deploy your application’s in no time. But, learning how to do that can be confusing, especially for PHP developers. In this tutorial I’ll cover basic steps which will help you to deploy your Laravel 4 application on Heroku. First let’s download Laravel:

After that, enter in laravel directory:

and initialize new git repository:

Now, create .gitignore file and put everything you want to ignore from git tracking. You can use Laravel’s default .gitignore file, just remove composer.lock from it:

And make a commit:

I assume that you have installed the Heroku Toolbelt, if you don’t have Heroku Toolbelt installed then just look at the install instructions and then continue with this tutorial.

Now, you need to login:

you need to enter your credentials and we’re ready to go. Let’s create our app:

heroku create command is used to create application called shop-up, with region parameter you can select region, stack parameter allows you to select on which stack you want to deploy your application and finally with buildpack parameter we can specify which buildpack we want to use for our application. In this case I used Heroku’s default PHP buildpack, and you can use whatever you want.

After executing this command we get following message:

Now, you just need to  create Heroku Procfile. You need to tell Apache2 web server that document root of your application is public/. Procfile should be placed in the root folder of your application. We just need to add one line to it:

Commmit changes and push you application to heroku repository:

After minute or two, you should get a message that tells you that your application is now deployed to Heroku:

And that’s it. Here is list of some useful commands that you may need:

In the next tutorial I’ll show you how you can add and use PostgreSQL database on your Heroku instance. Stay tuned.

 

Follow me

Mirza Pasic

Full Stack Developer at OLX
Web Developer. Geek. Systematic. Dreamer
Follow me

Published by

Mirza Pasic

Web Developer. Geek. Systematic. Dreamer

  • juneril

    i have problem when deploying an existing laravel app on heroku, , when i run it has an error:

    An error occurred in the application and your page could not be served. Please try again in a few moments.

    If you are the application owner, check your logs for details

    Trying to typ a comman heroku logs and errors are

    2015-02-04T08:40:05.848350+00:00 heroku[router]: at=error code=H10 desc=”App cra
    shed” method=GET path=”/” host=mindanaojobs.herokuapp.com request_id=b29a9f59-33
    d0-4c7c-8e6b-74d3ad87c497 fwd=”121.54.58.244″ dyno= connect= service= status=503
    bytes=
    2015-02-04T08:40:06.496079+00:00 heroku[router]: at=error code=H10 desc=”App cra
    shed” method=GET path=”/favicon.ico” host=mindanaojobs.herokuapp.com request_id=
    2c7d1fd5-2ad8-434a-b3f5-e663c3a297d7 fwd=”121.54.58.244″ dyno= connect= service=
    status=503 bytes=