Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Deploying multiple services on one cloud server instantly…

DZone's Guide to

Deploying multiple services on one cloud server instantly…

· Cloud Zone
Free Resource

What if you could learn how to use MongoDB directly from the experts, on your schedule, for free? We've put together the ultimate guide for learning MongoDB. Sign up and you'll receive instructions for how to get started!

There was a new release of Juju this week, 1.11.3, that brought a “small feature” with a big impact on your AWS bill. You are now able to deploy multiple services on one cloud server instantly. Before Juju started a new server per service which resulted in a potentially high AWS bill.

If you want to use the new feature you need to work with the development version of Juju Core. To install Juju on AWS just copy the below code into a file, e.g. installjuju.sh, make it executable: chmod u+x installjuju.sh and execute it: ./installjuju.sh

#!/bin/bash
echo "Installing Juju. Asks for your password."
sudo add-apt-repository ppa:juju/devel -y
sudo apt-get update -y
sudo apt-get install juju-core -y
if [ ! -f ~/.ssh/id_rsa ]; then
echo "Generating SSH Keys."
ssh-keygen -t rsa -b 2048
fi
if [ ! -f ~/.juju/environments.yaml ]; then
echo "Generating environments.yaml."
juju generate-config -w
fi
echo "Your AWS Access Key, followed by [Enter]:"
read awsaccesskey
echo "Your AWS Secret Key, followed by [Enter]:"
read awssecretkey
sed -i -e "s/# access-key: /access-key: $awsaccesskey/" ~/.juju/environments.yaml
sed -i -e "s/# secret-key: /secret-key: $awssecretkey/" ~/.juju/environments.yaml
echo "Bootstrapping Juju."
juju bootstrap

Afterwards you can start deploying services. If you want them to run on the same server you need to know the number of the server. Juju status will tell you this:

juju status

The bootstrap server is 0. New machines will be starting with 1 and go up. So if we want to install wordpress then we need to do the following:

juju deploy mysql --to 0 # deploy mysql to machine 0
juju deploy wordpress --to 0 # deploy wordpress to machine 0
juju add-relation mysql wordpress # create wordpress tables
juju expose wordpress # make wordpress accessible.
juju status # get the IP/URL of wordpress

Now you can log into WordPress. Your URL should look something like this:
http://ec2-<some numbers>-.compute-1.amazonaws.com

When you are done:

juju destroy-environment




What if you could learn how to use MongoDB directly from the experts, on your schedule, for free? We've put together the ultimate guide for learning MongoDBSign up and you'll receive instructions for how to get started!

Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}