As I prepare to go to Microsoft TechEd North America 2013 this weekend in New Orleans to work staff duty for Microsoft in the Windows Azure Conference Area, and coupled with the fact that I am reviving my skills in Linux Apache MySQL PHP (LAMP) I am going to do a blog on how easy it is to stand up a Ubuntu Linux Server 12.4 as a windows Azure Virtual Machine with LAMP installed and configured.
How do you get started with Azure
So, there are a few ways
- Use the Free Trial that is there
- Get a Subscription Outright
- As a Part of your MSDN/MVP/ other Microsoft Affiliation Program
In this blog we will be using it from the vantage point of an MSDN Subscription so if your Subscription has less or more, that’s probably why. As discussed however you can get Azure by signing up for the free version at http://windowsazure.com
If you have an account already you can just Log In from here as well.
Now that you are Logged In
So, as you can see, I have two items provisioned (1) Storage and (2) A Virtual Machine
Lets take a look at Storage first
If you are looking for a place to
The storage represented there can be used for just about anything except RDMS, its just simple storage. For me it is where the Virtual Hard Disk are stored, later on I can put whatever kind of storage I want actually. Now, although Azure gives you a way to interact with it, I prefer to use the Neudesic Azure Explorer tool. See below you can see that it has my VHD’s for all the Virtual Machines I built and are using now. Notwithstanding that, you can also store Tables and Queues in addition to the Blog Storage used to keep the Virtual Hard Disks.
We can save the conversation for another day for exploring the other uses of storage, but just to showcase the tool above lets see how you can create a new Table Storage
and once provisioned in the tool it looks like
But we came here to learn about using Azure to install Ubuntu in Azure so, lets get cracking. So from the bottom of the Azure Portal manager click New and lets set about creating a new Virtual Machine.
Once you click “Virtual Machine” the portal will fan out and you may elect to spin up your VM via the Quick Create which is easy but provides you with significantly less Configurable options as well as taking the most stringent of defaults (one being requiring you to SSH through a Certificate), so we will choose “From Gallery” as outlined below
Form the gallery we will ofcoourse be choosing the Ubuntu Server 12.04LTS but as you can see in the green call out, I could have used a previous Image Template that I have there. The point being that IF you OWN licenses to OS’s you can upload the image to Azure [via the Storage mechanism previously discussed] and they will appear in the template here.
Speaking of customization, well one of the things you can do in this Azure install is choose what Version Release of Ubuntu Linux you want, you achieve that by the selection below
The next set of decisions are very important ones that you will want to jot down somewhere, especially the UserName and Password one. Now you will notice that the credentials section “defaults” to uploading a certificate to Azure to let it know the box that you will be Secure Shell-ing in from. What that is THE best way to do this because it (1) encrypts the traffic (2) is overall more secure, we will not be doing that in this demo. Im my other ones, yes I do that.
So, in my case I am electing to do the password option
The next decision is one where advance preparation will make your life a lot easier. So, you recall how earlier we discussed that you can provision storage and use them at your own convenience. Well here is a good candidate for one. So, if this was production, I would definitely in advance of this selection set up a strong HA disk set for my storage and point it to that guy, as you see me doing here to this simple disk set.
Your next option is availability set, now this is just a Rip and Replace install so, I am not bothering with one, but you an read up here in the image as to what it is and how it is used.
When you complete that step, you will see that a Virtual Machine is being provisioned for you as below. the count to my Virtual Machine is now 2 up from 1
and after a few seconds/minutes, as seen below you will have a brand new Virtual Machine up and running
Logging In for the First Time
So first thing first right, this is Ubuntu Linux, it is NOT Windows so, that means that you WILL NOT be RDP-ing into this box, although there are Linux packages for that as well. Your access will be via Secure Shell (SSH) to issue command via the command line, or you could install the Desktop untop of your server, but with my limited knowledge of Linux, I still would advise against that. There are plenty of tools out there for you if you want to exchange files FileZilla comes to mind, and ofcourse if you are on a Windows Desktop you can use Putty to SSH in.
As for me, I have a Ubuntu Desktop 12.04 VM that is on my Dev Rig Laptop, I can bring it up and RDP into it that then SSH into my Server with my Certificate that I have. Below, you will see a few things, (1) the Public IP address of this VM instance and in my Ubuntu Desktop you will see me establishing a SSH session for the very first time. You will notice that I am not going over Port 22 which is the standard SSH, that is because Azure masks that with a Public Port to thwart folks with nefarious intent.
Once you try to establish that session you will get the below warning, go ahead and accept, this is your box afterall.
And once that is done, you will be authenticated into your Azure Instance of your Ubuntu Linux server as seen below
What do we do Next
Well ideally what we would do next is see if there are any updates and upgrades to be done to the Install by issuing the following command, but as i said, this is a rip and replace
$ sudo apt-get install updates
then if there are any after it identifies them
$ sudo apt-get install upgrade
After that happens then its time to get the LAMP installation done.
Installing the “M” out of LAMP – mySQL
So its time to install mySQL, as you can see below I am installing both the Server and the Client
I have the below screen shot only here once but as you install the “A” and the “P” out of Linux Apache MySQL PHP you will get this question again. So say “Yes” to them respectivly
For mySQL when you do the Install you will need to set the Root Password for it, go ahead and do so. You should jot this down again, because when we install phpMyAdmin, it is what we will be using to get into the Web Application.
Next is installing Apache, which is again, very straight forward…
Next you issue the command below to install PHP
Now after you install PHP, you will want to restart the Apache Service as you see below, and expect to see an “OK” coming back when it is done
Now that takes care of installing Ubuntu “L” then Apache “A” then mySQL “M” and then finally PHP “P” so there you go you have your LAMP server. Id also install or your favorite C compiler Im partial to installing build-essential
$ sudo apt-get install build-essential to get that going then you can crank out “C” and “C++” code on the box or you can put them in your CGI-BIN directory and call them from Apache
But for now, lets just make sure we can see the Apache Server from the Outside i.e. Public Internet. So to do that you will need open up a EndPoint AKA Port in Azure under your Virtual Machine, as you can see, so far its just the SSH port, but now we will add one for Port 80
Click Add EndPoint and then…
Name appropriately and Add it as seen below in the screen shot
Once you have done that you should be able to call up the URL from any browser and see the standard Welcome Page for an Apache Server as seen below
Well that does it for making sure that Apache is up and running but to test for PHP, you will need to create a simple script and copy it to the publishing folder where Apache reads from. Now ideally here again, I would move that folder from /var/www and put it soemwhere else, but for now we are using the default. In this example I am creating the file in my home directory using the VI editor, ofcourse you can use anyone you desire, some find “nano” or “pico” easy to use, even though VI has a steeper leaning curve, it is by far the most powerful IMO.
Below is the basic script everyone uses to prove out PHP running
Once you have done that then you need to copy this file to where Apache reads web pages from as previously discussed.
Once you have completed that copy, you can now call that page from any public browser and see the results as shown below.
One more piece of tool, I will install before calling it quits on this LAMP Server.
So this is a great tool for managing mySQL, certainly more control can be gained by using the command line tools but this is more visual and is good IMO. So issue the command below to install it.
Once you do, this is another Web App available to anyone with rights and credentials.
Once you are in. The world is your oyster.
Now even though I get Azure with my MSDN subscription, I am not about to leave Servers I dont need running, and I have all but shown you all how to access my server from anywhere, so I am going to decommission it and delete it from Azure. Those steps are also very easy. First locate your Server from your list of VM’s and say Delete
Then Confirm the Delete. You can also delete the VHD as well that is in the Storage.
Below is the Azure Management Console telling me about the delete process
And now my virtual machines are now Down from 2 to 1
Azure is good, easy, great for Rip and Run scenarios, Proof of Concepts or Learning New stuff. Take it easy Irie.