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.
$ cd /home/user/lampstack-version $ ./use_lampstack
There is a shortcut in Start -> BitNami WAMP Stack ->"UseBitNami WAMP Stack"
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: 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: firstname.lastname@example.org 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.
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:
... 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
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 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/ | firstname.lastname@example.org: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 (188.8.131.52)' 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,184.108.40.206' (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 email@example.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 firstname.lastname@example.org:gentle-temple-3910.git 2df113f..522ec8a master -> master
And test if it works:
$ curl http://gentle-temple-3910.herokuapp.com/test.txt hello world