One of Ubuntu’s biggest advantages is the simplicity of the APT package system. You find a desktop program you want, issue a command, and it’s ready to run. For server-side application, however, this APT installation sometimes only installs the files you’ll need to run the program – you’ll need to set up and run the program (often a service or daemon) yourself. But the juju system aims to make access to server-based programs as simple as those for the desktop. Here’s how to use it.
Installation and Initial Set-up
Setting up juju is a little more involved than, for example, installing a LAMP stack using tasksel, as it’s designed for cloud environments. First, we’ll need to install juju and its dependencies:
sudo apt-get install juju libvirt-bin lxc apt-cacher-ng libzookeeper-java zookeeper
Note: while there is a version of juju in the Universe repositories for Precise, the “Juju hackers” team has some PPA’s with updated versions. I’ll be using the version from the repositories.
Once this is completed, you’ll need to generate an SSH key for your server, if you don’t have one already:
ssh-keygen -t rsa
Lastly, your user will need to be a group associated with the virtualization daemon libvirtd:
sudo usermod -a -G libvirtd [your username]
This is because your juju environment is actually a virtual Ubuntu environment within your current machine. Next, you’ll need to initiate the “bootstrap” process, where this virtual environment is downloaded and installed:
Oops! We’re missing a configuration file… thankfully, juju has at least created a sample for us. Using your text editor of choice, edit the file ~/.juju/environments.yaml to match the following:
default: wordpress environments: wordpress: type: local admin-secret: [create a unique phrase here] default-series: precise data-dir: /home/[your username]/[a directory you choose]
Now, if you’re able to take the server down, rebooting will ensure all the services are started correctly. Let’s go get some charms.
Installing and Running Charms
As mentioned, Charms are similar to APT packages, but are also focused on all the things that need to happen to get a service running. We’ll deploy an instance of WordPress as an example here with the following command:
juju deploy wordpress
Now we should be able to go to the IP address of our server and get to blogging… we can confirm that WordPress is running with the following command:
But wait, there’s an error here! This is because juju doesn’t automatically handle dependencies. WordPress requires a MySQL database to work, and this wasn’t installed automatically. Let’s get this set up:
juju deploy mysql
Now we need to connect the two together:
juju add-relation wordpress mysql
Lastly, let’s make it visible to the world:
juju expose wordpress
At this point is the hardest part of the process: patience. While these commands will have seemed to complete, there will actually be a fair number of things happening in the background – specifically, the download, installation, and configuration of the “virtual” Ubuntu environment. You’ll notice two listings under “services:” when you issue the
juju status command, one called “wordpress” (this is the actual WordPress instance) and “mysql” (this is the MySQL instance). Beneath each, there is a “agent-state” line, which will likely say “pending.” You may also hear your hard drive churning… that’s OK, that’s just a lot of packages being installed (check the results of
ps ax to see some of what’s going on).
Suffice to say, you’ll need to wait until both of the services list “agent-state: started.” Keep using
juju status to check on the progress. Once they are both started, you can see your WordPress installation by visiting the IP address listed in the “public-address” line of the output of
juju status (mine was http://10.0.3.66).
Our latest tutorials delivered straight to your inbox