Deploying PHP Apps to Heroku
As an example, we'll deploy a quick phpinfo.php file to Heroku.
Prerequisites: Heroku Gem | Account Setup
1. Create an empty project and Git Repository
mkdir heroku-php
cd heroku-php
git init
2. Create our test file and commit to Git
vim index.php
Place the following text inside here:
<?php phpinfo(); ?>
Now add to git:
git add index.php
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 freezing-winter-5984... done, stack is cedar
http://freezing-winter-5984.herokuapp.com/ | git@heroku.com:freezing-winter-5984.git
Git remote heroku added
Now push to the repository:
git push heroku master
The response should now look a little like:
Counting objects: 3, done.
Writing objects: 100% (3/3), 244 bytes
Total 3 (delta 0), reused 0 (delta 0)
-----> Heroku receiving push
-----> PHP app detected
-----> Bundling Apache v2.2.19
-----> Bundling PHP v5.3.6
-----> Discovering process types
Procfile declares types -> (none)
Default types for PHP -> web
-----> Compiled slug size is 21.5MB
-----> Launching... done, v4
http://freezing-winter-5984.herokuapp.com deployed to Heroku
To git@heroku.com:freezing-winter-5984
* [new branch] master -> master
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 http://freezing-winter-5984.herokuapp.com.
Comments
Be the first to comment!