Thursday, March 14, 2013

PHP App in Heroku for Noob

Everything you need to get started using Heroku


First, sign up an account. https://api.heroku.com/signup

Then, install Heroku client. This is a CLI tool for creating and managing Heroku apps. This script will install Heroku, foreman and Git if you haven't got them installed.
wget -qO- https://toolbelt.heroku.com/install-ubuntu.sh | sh


Once installed, login in using the email address and password to access Heroku.
heroku login


Now you're ready to create your first Heroku app. The arguement --stack cedar tells Heroku to make it a PHP server. In this tutorial, the apps name "ohaiya" is the application name Heroku created. Get some other names i.e. annyeonghaseyo XP
heroku create ohaiyo --stack cedar


Before you connect to Heroku server, you might need to add the public keys. Else you'll get an error saying "Permission denied (publickey)".
heroku keys:add


Clone the app from Heroku server. Then you can start coding right away.
git clone git@heroku.com:ohaiyo.git -o ohaiyo


An example code I wrote.



Now we'll update the repository in Heroku server.
git add -A
git commit -am "first commit"
git push ohaiyo master



Check out your code live!

No comments: