Deploy A Toy PHP Application On AppFog11 Mar 2013
A tutorial to get you started with AppFog in PHP. And because “Hello World” is boring, I’ll do a “Drink Coffee” app!
Command line tool
After creating an account on AppFog, install AppFog’s command line tool by following their instructions. Depending on your system, it can be either very easy or quite a pain. Good luck!
Once you have
af installed, log in by
$ af login Attempting login to [https://api.appfog.com] Email: firstname.lastname@example.org Password: ********* Successfully logged into [https://api.appfog.com]
Create your PHP app:
$ mkdir drink-coffee $ cd drink-coffee $ echo '<?php echo "Drink coffee!"; ?>' > index.php
Then deploy! (Default values are all good)
$ af push drink-coffee Would you like to deploy from the current directory? [Yn]: Detected a PHP Application, is this correct? [Yn]: 1: AWS US East - Virginia 2: AWS EU West - Ireland 3: AWS Asia SE - Singapore 4: Rackspace AZ 1 - Dallas 5: HP AZ 2 - Las Vegas Select Infrastructure: 1 Application Deployed URL [drink-coffee.aws.af.cm]: Memory reservation (128M, 256M, 512M, 1G, 2G) [128M]: How many instances? : Create services to bind to 'drink-coffee'? [yN]: Would you like to save this configuration? [yN]: Creating Application: OK Uploading Application: Checking for available resources: OK Packing application: OK Uploading (0K): OK Push Status: OK Staging Application 'drink-coffee': OK Starting Application 'drink-coffee': OK
You can go on the url given and see your app up and running.
If you go on the AppFog console at console.appfog.com, you will see your app and status:
Updating your application is easy as well.
$ echo '<?php echo "Go drink coffee!"; ?>' > index.php $ af update drink-coffee Uploading Application: Checking for available resources: OK Packing application: OK Uploading (0K): OK Push Status: OK Stopping Application 'drink-coffee': OK Staging Application 'drink-coffee': OK Starting Application 'drink-coffee': OK