Heroku Client

    Install BitNami AMP/APP stacks

    BitNami AMP/APP stacks are available for download at BitNami.com page. Choose the installer apropriate for your operating system and architecture. Note that the version could be different. The Heroku client was included in AMP/APP stacks since 5.4.11-1 version.

    To begin the installation process, double-click on that file and continue with the installation process. Learn more about the LAMP stack and the bundled component versions.

    Configure Heroku Client

    Before you continue with this guide, you need to sign up for the Heroku account.

    You will need a ssh key to be able to deploy your application to Heroku. If you already have a SSH key, you can add it in the Heroku dashboard. If you do not have one or if you want to generate a new one only for Heroku, you can create it.

    Log in the BitNami AMP/APP console. It depends on the platform.

    linux_platform.png On Linux:

    $ cd /home/user/lampstack-version
    $ ./use_lampstack
    

    win_platform.png On Windows:

    There is a shortcut in Start -> BitNami WAMP Stack ->"UseBitNami WAMP Stack"

    mac_platform.png On OS X:

    Open a Terminal and type the following:

    hostname:~ user$ cd /Applications/mampstack-version
    hostname:~ user$ ./use_mampstack
    

     

    Configure your Heroku client and bind it to your Heroku account executing the following command:

    $ heroku login
    Enter your Heroku credentials.
    Email: your_email@example.com
    Password (typing will be hidden): 
    Found existing public key: /home/user_name/.ssh/my-heroku-key-rsa.pub
    Uploading SSH public key /home/user_name/.ssh/my-heroku-key-rsa.pub... done
    Authentication successful.
    

    You can upload your SSH key or you can create a new one:

    $ heroku login
    Enter your Heroku credentials.
    Email: your_email@example.com
    Password (typing will be hidden):
    Could not find an existing public key.
    Would you like to generate one? [Yn]
    Generating new SSH public key.
    Uploading ssh public key /home/user_name/.ssh/id_rsa.pub
    

     

    Important: On Linux the SSH key will be created in the following folders. If you use your own SSH keys, check that you copied the private and public keys in the same location.

    Linux: "/home/user_name/.ssh/id_rsa"
    OS X: "/Users/user_name/.ssh/id_rsa"
    Windows:  "C:\Users\user_name\.ssh\id_rsa" (or at "C:\Documents and Settings\user_name\.ssh\id_rsa" for older Windows versions).

    Check if everything works properly listing apps already running in your Heroku account:

    $ heroku apps
    You have no apps.
    

    Create a sample PHP application

    BitNami AMP/APP stacks ship a sample project that you can deploy in Heroku. This sample application could be accessible from the browser in your exising AMP/APP stack. The application files are in the "/installdir/apps/heroku/htdocs" folder.

    To enable the Heroku sample application in your current installation, it is only necessary to uncomment the following line at the bottom of the Apache configuration file:

    /installdir/apache2/conf/httpd.conf

    ...
    Include /installdir/apps/heroku/conf/heroku.conf
    

    Once you enabled it, restart the Apache server from the Manager graphical application or from the command line (on OS X or Linux):

    $ cd installdir
    $ ./ctlscript.sh restart apache
    

    You can see now the sample heroku application in your browser at http://your_domain/heroku or http://your_domain:8080/heroku

    heroku-welcome.png

    If it does not work, check the Apache log file to see if there was any error.

    Now, it is necessary to setup the git repository for your application:

    $ cd installdir/apps/heroku/htdocs
    $ git init
    Initialized empty Git repository in /installdir/apps/heroku/htdocs/.git/
    $ git config --global user.email your_email@example.com
    $ git config --global user.name "Your Name"
    $ git add .
    $ git commit -m "My PHP app first commit" .
    [master (root-commit) 2df113f] my PHP app first commit
     1 file changed, 1 insertion(+)
     create mode 100644 index.php
    


    Create a new Heroku application and deploy your code:

    $ heroku create
    Creating gentle-temple-3910... done, stack is cedar
    http://gentle-temple-3910.herokuapp.com/ | git@heroku.com:gentle-temple-3910.git
    Git remote heroku added
    

     

    This command returns the server name, in this case "gentle-temple-3910.herokuapp.com".

    $ git push heroku master
    The authenticity of host 'heroku.com (50.19.85.132)' can't be established.
    RSA key fingerprint is 8b:48:5e:67:0e:c9:16:47:32:f2:87:0c:1f:c8:60:ad.
    Are you sure you want to continue connecting (yes/no)? yes
    Warning: Permanently added 'heroku.com,50.19.85.132' (RSA) to the list of known hosts.
    Counting objects: 3, done.
    Writing objects: 100% (3/3), 250 bytes, done.
    Total 3 (delta 0), reused 0 (delta 0)
    -----> PHP app detected
    -----> Bundling Apache version 2.2.22
    -----> Bundling PHP version 5.3.10
    -----> Discovering process types
           Procfile declares types -> (none)
           Default types for PHP   -> web
    -----> Compiled slug size: 9.5MB
    -----> Launching... done, v4
           http://gentle-temple-3910.herokuapp.com deployed to Heroku
    
    To git@heroku.com:gentle-temple-3910.git
    * [new branch]      master -> master
    

    Visit your application at the domain that heroku returns gentle-temple-3910.herokuapp.com. You can change this domain name from the Heroku dashboard.
     

    Keep developing your application

    Add new application components, modify your code and test it locally with BitNami LAMP stack:

    $ echo "hello world" > test.txt
    $ curl http://localhost:8080/heroku/test.txt
    hello world
    

    Commit your changes to your local git repository once it is already tested.

    $ git add test.txt
    $ git commit -m 'adding test.txt'
    [master 522ec8a] adding test.txt
     1 file changed, 1 insertion(+)
     create mode 100644 test.txt
    

    Deploy new version to Heroku:

    $ git push heroku master
    Counting objects: 4, done.
    Compressing objects: 100% (2/2), done.
    Writing objects: 100% (3/3), 295 bytes, done.
    Total 3 (delta 0), reused 0 (delta 0)
    -----> PHP app detected
    -----> Bundling Apache version 2.2.22
    -----> Bundling PHP version 5.3.10
    -----> Discovering process types
           Procfile declares types -> (none)
           Default types for PHP   -> web
    -----> Compiled slug size: 9.5MB
    -----> Launching... done, v5
           http://gentle-temple-3910.herokuapp.com deployed to Heroku
    
    To git@heroku.com:gentle-temple-3910.git
       2df113f..522ec8a  master -> master
    

    And test if it works:

    $ curl http://gentle-temple-3910.herokuapp.com/test.txt
    hello world
    
    Tag page (Edit tags)
    • No tags
    Page statistics
    22836 view(s), 16 edit(s) and 8449 character(s)

    Comments

    You must login to post a comment.

    Attach file

    Attachments

    FileSizeDateAttached by 
     heroku-welcome.png
    Heroku sample project
    52.3 kB12:30, 19 Feb 2013AdminActions