== Open Week -- Deploying Web Applications in the Cloud -- DustinKirkland -- Wed, Oct 13 == {{{#!IRC [18:01] Logs for this session will be available at http://irclogs.ubuntu.com/2010/10/13/%23ubuntu-classroom.html following the conclusion of the session. [18:01] howdy howdy howdy! [18:01] alright [18:01] so continuing on with the cloud theme, i'll invite you to join me for a real live demo [18:02] if you would be so kind as to: [18:02] ssh -C guest@ec2-174-129-94-110.compute-1.amazonaws.com [18:02] the password is 'guest' [18:02] i'll wait just a minute for people to log in [18:03] when you get in, you should see a shared Byobu session [18:03] with the matrix screen saver running [18:03] i have write access [18:03] everyone else should have read only access [18:03] now, i'm going to go through a few examples in that window, that everyone will be able to see [18:03] however, you're welcome to do the same things on your own system [18:04] all of what i'm going to do will work on your Ubuntu desktop, server, or virtual machine [18:04] and if you haven't already, go to http://10.cloud.ubuntu.com for your free hour of Ubuntu in the Cloud :-) [18:04] okay, so yeah, a free hour in the cloud ... as many people have asked [18:04] "so I logged in, and that's cool, but .... now what?" :-) [18:05] well, i find cloud instances great places for writing and deploying web applications [18:05] many web apps are small, and lightweight, and can work very well in a virtualized cloud environment [18:05] i'm going to go through a few examples of some sample web apps [18:05] you may or may not be interested in the particular applications that i demo [18:05] but hopefully they'll give you a good idea [18:06] alrighty, any questions before we get started? [18:06] great ... [18:07] alright, so first, we're going to deploy a web app in this cloud instance that will allow us to share pictures over the web [18:07] there are lots of public ones available, like Flickr, Picasa, etc. [18:07] and those are certainly great for what they are [18:07] but sometimes, perhaps, you want to run the server yourself [18:08] or, you don't want to upload your pictures to a 3rd party [18:08] or perhaps you just want to tinker with the source code, like me :-) [18:08] Ubuntu includes a number of such web apps [18:08] i'm going to show you how to deploy, configure, and install one such [18:08] and I picked it because I wrote it as a college student in 1999 :-) [18:09] sudo apt-get install pictor [18:09] i'm doing that in the shared screen session now [18:09] now i've got a stack of dependencies that are going to be installed [18:09] http://pastebin.ubuntu.com/512507/ [18:09] ^ if you're not following in screen [18:10] notice how fast these download and install in the cloud :-) [18:10] this is because Canonical provides a mirror of the ubuntu archive in EC2 itself [18:10] note that you're not charged for network bandwidth inside of EC2 [18:10] okay, cool, so now pictor is installed [18:10] let's point our web browser to it [18:12] um, i see i have an error message :-) one second ... [18:12] Your apache2 configuration is broken, so we're not restarting it for you. [18:13] (sorry, i just set this up before the session, purged it uncleanly) [18:14] okay, sorry [18:14] http://174.129.94.110/pictor/ [18:14] now it's up [18:14] so that's the default landing page of pictor [18:14] to review ... [18:15] sudo apt-get install pictor [18:15] i had to sudo service apache2 restart [18:15] then point a browser to http://174.129.94.110/pictor/ [18:15] there, i see an error message [18:15] ERROR [18:15] No pictures found. [18:15] Create a symlink to your pictures folder at [18:15] /usr/share/pictor/pictures [18:15] so i've seeded this instance with a few pictures [18:16] in ubuntu's home directory, we should see a Pictures dir [18:16] which you also have on your Ubuntu desktop [18:16] inside of the Pictures dir there can be a list of sub dirs [18:16] and subdirs can have subdirs, etc. etc. etc. [18:16] and so on [18:17] our error message at http://174.129.94.110/pictor/ says that we need a symlink [18:17] to tell pictor where our pictures are located [18:17] which is /home/ubuntu/Pictures [18:17] let's do this... [18:17] sudo ln -s /home/ubuntu/Pictures /usr/share/pictor/pictures [18:17] now refresh http://174.129.94.110/pictor/ [18:18] and you should see a list of the available albums [18:18] click on one of them, and you should either see more subdirs, or thumbnails of pictures [18:19] looks like my upload did not complete [18:19] anyway, you get the 'picture' ;-) [18:19] * kirkland finishes syncing [18:20] click on a given picture, and you get meta data details about the photo [18:20] you can dynamically resize, rotate it, etc. [18:20] let's take a quick look where this is happening ... [18:20] cd /var/cache/pictor [18:20] ls [18:21] resize thumbnails [18:21] there's a set of thumbnails cached here, which are taken out of the JPEG headers (if available), and if not, it uses ImageMagik to create and cache a thumbnail [18:21] we can clear this cache at any time, and it just gets rebuilt [18:21] ubuntu@ip-10-202-194-3:/var/cache/pictor/thumbnails$ sudo rm -rf * [18:22] now, just refresh http://174.129.94.110/pictor/?album=/Puppies/2007-12-17&thumbs=1 [18:22] note that it's easy to drop an .htaccess file in here and make this password protected [18:23] if you wanted to make these somewhat more "private" [18:23] and there's no database at all [18:23] all of pictor is driven from the filesystem and metadata included in the JPG [18:23] so it's trivial to move pictures around [18:23] upload more, etc. [18:24] also, it comes with a handy little utility called "pictor-unload" [18:24] which you can use to keep pictures from multiple cameras in sync [18:24] so if i'm shooting with one camera, and my wife is shooting with another [18:24] and their two clocks are in sync [18:25] we can unload the two flash cards, and name the pics accordingly [18:25] let me try to fake a demo of that ... [18:25] since clouds don't have flash media :-) [18:26] okay, let's pretend that /media/flash is my flash disk [18:26] and in there, there's a subdir of some pictures [18:26] and i want to "unload" those [18:27] let's make a new destination directory [18:27] pictor-unload /media/flash /home/ubuntu/Pictures/More\ Puppies [18:28] okay, now i have a copy of the pics in the current dir, renamed with their timestamp on the front [18:28] this helps keep things in order [18:28] and now, goto http://174.129.94.110/pictor/?album=/More+Puppies&thumbs=1 [18:29] and you see that the new pics are up already [18:29] okay ... so that a whirlwind tour of pictor [18:29] a fun little web app to deploy in the cloud (though you could just as easily do so on a server or a desktop) [18:29] let's now take a look at it's more musical cousin ... [18:29] musica [18:30] musica is a web app for streaming music [18:30] it's a nice way of accessing your entire music library remotely [18:30] (and another web app i wrote in college, back in 1998-1999) [18:30] sudo apt-get install musica [18:31] alrighty, just like that, musica is now installed [18:31] now, point your browser to http://174.129.94.110/musica/ [18:31] once again, we see that we need to put a symlink in place to tell musica where to find our tunes [18:32] and once again, i've preloaded this cloud instance with a few tunes from some of my musical friends [18:32] can everyone get to http://174.129.94.110/musica/ okay? [18:33] alright, now let's create that symlink [18:33] sudo ln -s /home/ubuntu/Music /usr/share/musica/music [18:33] and refresh http://174.129.94.110/musica/ [18:33] there's a couple of frames to this webpage [18:33] (yeah, i wrote most of this long before ajax existed) [18:34] the left most is a list of artists [18:34] which include my buddy "Jeff Luna" and his zaney comedic tunes [18:34] and Last Chance Dave -- a couple of guys with some nice soulful rock [18:34] clicking on either of them will show the albums that i have [18:34] for that artist [18:35] clicking on an album will then launch a flash based player [18:35] called jplayer, which is embedded [18:35] from there, you have the basic streaming functionality [18:35] play/pause, skip around, volume, etc. [18:36] you can also download an m3u playlist, or a tarball of the whole album [18:36] now, let's add some new tunes to our library [18:36] in case you missed it, jono's band, Severed Fifth released a new album this week-ish [18:37] it's freely downloadable from http://www.severedfifth.com/releases/ [18:37] wget http://audio.lugradio.org/severedfifth/nightmaresbydesign/severedfifth-nightmaresbydesign-2010-ogg.zip [18:37] and we watch that download to our cloud instance [18:37] .... done [18:46] sorry , network connectivity issue [18:46] :-( [18:46] tethered through phone now [18:46] okay, let's get some new music [18:47] now try refreshing http://174.129.94.110/musica/ [18:48] okay, so that's pretty much musica [18:48] again, like pictor, it's easy to add an .htaccess [18:48] and authenticate through [18:49] to "protect" your pictures and music [18:49] it's also easy to add SSL to the apache configuration [18:49] this is where the embedded player is really nice [18:49] it doesn't even need to know about that at all [18:50] There are 10 minutes remaining in the current session. [18:51] QUESTION: why aren't the severed fifth tunes playing? [18:51] IdleOne: possibly a bug in ogg support in jplayer, i'll need to take a look at that one [18:51] let's try to get to some questions [18:51] i had hoped to deploy a wordpress instance and a moodle server [18:51] i can do those quickly, without much detail if you like [18:51] or i can field some questions [18:52] Question:I loged into the cloud but I can see some letters scrolling ,..is it the same expected [18:52] that was the program 'cmatrix' [18:52] :-) [18:52] supposed to look like the matrix [18:52] i think it's a fun screen saver for servers :-) [18:52] Question:How long we cloud computing if try 10.ubuntu cloud page [18:53] those instances only last about ~1 hour [18:53] so it's really just for test driving [18:53] you can buy your own instance though, if you like [18:53] and keep it as long as you're willing to pay Amazon for it [18:53] (ubuntu is free though) [18:53] is that the standard-issue byobu profile? [18:53] i've tweaked a couple of things [18:54] i wanted to see the ec2-cost, network traffic, and number of people logged in [18:54] QUESTION: So basically pictor is a photo gallery program, but what is needed on a web server for it? [18:55] yeah, that's it basically; sudo apt-get install pictor will install all of its web server dependencies [18:55] There are 5 minutes remaining in the current session. [18:59] 17:56:32> QUESTION: How do these instances actually get created with CLOUD? [18:59] i created this instance using ec2-run-instance [18:59] and picked an image from http://uec-images.ubuntu.com/maverick/current/ [18:59] i used screenbin(1) to set it up for this classroom setting [18:59] where i have write access you have read access [19:00] 17:56:29> Please proceed with wordpress then [19:00] installing now ... [19:01] Logs for this session will be available at http://irclogs.ubuntu.com/2010/10/13/%23ubuntu-classroom.html [19:01] QUESTION: so how is deploying an app to a cloud any different from applying to Ubuntu Server. I am guessing the answer is that it isn't. Just ssh and sudo apt-get install -y. Is that correct? [19:01] autif: mostly the same }}}