Getting Started With Azure Linux VMs |
Written by Mike James | ||||
Thursday, 17 April 2014 | ||||
Page 2 of 3
Setting up the VMNow that you have a certificate you can move on to creating the Linux VM. This takes the usual set of steps. Click the NEW icon and select Compute,Virtual Machine, From Gallery.
Next select the OS you prefer - I'm going to use Ubuntu Server 12.04 because that's what I'm familiar with. Next select the configuration you want - I chose BASIC, A0 and left the user name azureuser as the default. To upload the certificate you prepared earlier select BROWSE FOR FILE and locate the .pem file you created - myCert.pem in this case. You can also set a password which you can use in place of a certificate but I would advise against. You can accept most of the defaults on the final configuration page or adjust them as suits your purpose. If you are setting up a LAMP system also need to add port 80 and 21 if you also want to run an FTP server. You can add these later if you want to. Once configuration is completed you will have to wait while the machine is provisioned and started. Connecting To The Machine - PuTTY.Once the machine is provisioned and running it is time to connect. to it using SSH. There are a number of SSH Terminals you can use but PuTTY is simple and the one most used. To use it you need two components PuTTY itself and PuTTYgen. Both as simple exe files and they don't need installing. Just download them somewhere sensible and run. You can get both from: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html The first thing you have to do is use PuTTYgen to create a private key PPK file from the certificate. PuTTY can't just read the certificate to extract the key you have to do it for it. Simply run PuTTYgen and use the File, Load a Private Key command and find your certificate .pem file again. Once the file is open you can save the key using the Save private key button. This creates a .ppk file that you can use with PuTTY. Next run PuTTY. Copy and paste the host name into the Host Name or IP address window Lamp1.cloudapp.net in the case of our example. The only other thing you have to do is set the Connection method and Authentication method. Select Connection, SSH and Auth and in the box Private key file for authentication use the Browse button to enter the .ppk file we created using PuTTYgen. You can customize other features of the connection such as font etc but the DNS name and the private keyfile are all that are really necessary. It is probably worth saving the connection to use again under a descriptive name. Next you can open the connection and after dismissing the warning about trusting the remote machine you can log in. All you need to supply is your user name - the certificate and the private key act in place of a password.
(click to enlarge)
That's all you have to do. From now on you can log into the remove machine just using your user name - no password necessary. LAMPOur next task is to convert our raw Ubuntu Server into a LAMP stack. What might surprise most Windows users is that this can be done with one single command, well if you want to be on the safe side two commands. First make sure that the package lists are all up-to-date so that you will get the newest versions of the packages you are about to install:
If you are new to Ubuntu and Debian based Linux all you need to know is that you use "sudo" to run commands as root i.e. as an administrator and apt-get is the command to load packages. To load the minimum packages you need for a LAMP system you simply use the command:
OK, perhaps this is a bit of a cheat as this is one very long command and it could be entered as individual commands to load each package. If you are worried about having to type everything into a command prompt and are already longing for the ease of use of a GUI then it is worth point out that you can do most of what you need to do with copy and paste. You need to know that you can edit what is already on the command prompt using the cursor keys and you can scroll though previous commands with the up and down cursor keys. You can also paste anything you have copied using the right mouse button in PuTTY. (This can be configured differently.) So you can simply copy and paste the big command and then follow though the prompts it generates. First it works out the total size of the packages you are about to install an then asks you if this is OK. Unless you have changed your mind about setting up a LAMP system, the correct answer is Y. The Apache web server is installed in a default configuration without you being asked any questions. MySQL gives you the chance to apply a password to the root users account. It is a good idea to supply a password even for a development system because any programs you create will have to work with passwords in the real world so you might as well tackle this problem from the start. Don't forget the password and when you need to log on to MySQL you will use root,password. When the scrolling text messages about what is happening finally end you will be back at the command prompt. Everything should now just work and be setup as the documentation describes with no extras. To check that things are working simply point your browser at the URL listed in the Azure dashboard for the machine - http://lamp1.cloudapp.net/ in the case of our example. You should see the default Apache web page which simply ways "It works". The document root for the website is /var/www and you can copy the files for you own website into this location - but how? FTPThe easy solution to getting your files onto the VM is to use FTP or rather, as you have gone to the trouble of creating a certificate, SFTP. You could install an plain FTP server, but why bother. All you need is an SFTP client - I use FileZilla. In the case of FileZilla all you have to do to connect to your new LAMP server is go to the Site Manger and set up a new site with host set to the URL that you used to test Apache - minus the http of course, select SFTP as the protocol and enter your user name as part of a Normal Login Type. You don't need a password because FileZilla will accept a .PPK file containing the private key you are using with PuTTY. To load the key simply us the command Edit,Settings and select SFTP from the menu and load the .PPK file containing the key. With the key loaded you can connect to the Lamp VM and start to transfer files. When you first connect you will be in the home directory, but you can navigate to any directory you like. |
||||
Last Updated ( Thursday, 17 April 2014 ) |