Pages

Saturday, April 12, 2014

How to configure herokuapp to run php driven website

Hi,
          Now a days ,there are so many webhosting providers are in the market.Some of the examples are AWS,whm,cpanel etc.I have found one good webhosting service for free or paid service with some extra features.I am talking about "HEROKUAPP".It is very simple to configure but for those who are not aware about how to configure it is extreme difficult.I will explain how to configure your php website with herokuapp step by step.


  1. First create heroku account from heroku website https://herokuapp.com/ 
  2. To configure heroku client(herokuapp) in your unix based machine ,you have to first install heroku tool called "heroku toolbelt" in your machine.As heroku works on git based platform.You can download it heroku toolbelt from here.
  3. After successful installation ,create one folder of any name where you will put your php website code.
  4. change directory to folder that you have created and type command "heroku login".It will ask for your email id and password that you created with heroku account.It will find existing public key,and if not found it will ask to generate new one.Type Y to create new one.
  5. Now you have configured heroku app in your linux machine.First time you will have to configure heroku stack to run website with php environment.We need to configure Cedar stack to run website with php environment in heroku.You can configure it by running : heroku create -s cedar
  6. You will get output like below: Creating abc-def-345.. done, stack is cedar http://acd-def-345.herokuapp.com/ | git@heroku.com:abc-def-345.git Git remote heroku added
  7. Now you are done.Just put your final website code in your folder that you created earlier,changed directory to that folder and run below commands:
          1.sudo git init
    2.sudo git add *
    3.sudo git commit -m "Your own comment"
    Don't forget to mention comment with -m otherwise it will not commit.
     4.As we have configured email and user initially,if not then configure it by
    git config --global user.email <your heroku account email address>
    git config --global user.name <your name>
    5.then type below command to add remote repo
    sudo git remote add heroku git@heroku.com:abc-def-345.git
    6.Run below command to push all your website data in the directory to heroku repo
    git push heroku master
    7.If you get error then run above command with --force option
    git push heroku master --force
    8.You are done all your php website data is loaded into heroku.
    9.Every time you upload new file or update old file.You will have to run below commands:
  • sudo git add *     
  • sudo git commit -m "Your own comment"
  • git push heroku master
        10.You don't need to login everytime,it will require only first time.

        11.Just for your information that herokuapp is readonly system.So you can not upload any data uploaded from client side to your folders,It will autodelete in few hours of interval.
You can access your heroku webpage by typing http://abc-def-345.herokuapp.com.

                 How to configure mysql or postgresql with php in herokuapp,you will get it in my next knowls.

To configure mysql in herokuapp click here
    

Shell Script Code