Você está na página 1de 19

DeployingOpenSourceSoftwareon

MicrosoftAzure

HandsonLab

Terms of Use
2016 Microsoft Corporation. All rights reserved.
Information in this document, including URL and other Internet Web site references, is subject to
change without notice. Unless otherwise noted, the companies, organizations, products, domain
names, email addresses, logos, people, places, and events depicted herein are fictitious, and no
association with any real company, organization, product, domain name, email address, logo,
person, place, or event is intended or should be inferred. Complying with all applicable copyright
laws is the responsibility of the user. Without limiting the rights under copyright, no part of this
document may be reproduced, stored in or introduced into a retrieval system, or transmitted in
any form or by any means (electronic, mechanical, photocopying, recording, or otherwise), or for
any purpose, without the express written permission of Microsoft Corporation.
For more information, see Microsoft Copyright Permissions at
http://www.microsoft.com/permission
Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual
property rights covering subject matter in this document. Except as expressly provided in any
written license agreement from Microsoft, the furnishing of this document does not give you any
license to these patents, trademarks, copyrights, or other intellectual property.
The Microsoft company name and Microsoft products mentioned herein may be either registered
trademarks or trademarks of Microsoft Corporation in the United States and/or other countries.
The names of actual companies and products mentioned herein may be the trademarks of their
respective owners.
This document reflects current views and assumptions as of the date of development and is
subject to change. Actual and future results and trends may differ materially from any
forwardlooking statements. Microsoft assumes no responsibility for errors or omissions in
the materials.
THIS DOCUMENT IS FOR INFORMATIONAL AND TRAINING PURPOSES ONLY AND IS
PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT.

2016MicrosoftCorporation.Allrightsreserved.

TableofContents
Lab Environment ............................................................................................................................................................. 1
Lab Overview ..................................................................................................................................................................... 2
Lab Exercise ....................................................................................................................................................................... 3
Useful Links ...................................................................................................................................................................... 15

DeployingOpenSourceSoftwareonMicrosoftAzureLabEnvironment

LabEnvironment
During this lab, you will work in a simulated environment with the following computers or
virtual machines.

ComputersandVirtualMachinesUsedinThisLab

Icon

ComputerName

MicrosoftAzure

SERVER1

Description
YouwillperformthesetasksintheMicrosoftAzure
portal@http://portal.azure.com

ThisisastandaloneserveronAzure.

LogonCredentials
Lab Setup
Virtual Machines: DC1 and Server1
User account: CONTOSO1\administrator
Password: P@ssw0rd
The lab environment might require you to log on to the Handson Lab Environment using the
following credentials, unless specified differently throughout the lab manual.
Username
LabUser

Password
LabPassword1

2016MicrosoftCorporation.Allrightsreserved.

DeployingOpenSourceSoftwareonMicrosoftAzureLabOverview

LabOverview

Abstract

During this lab, you will run several exercises to install a LAMP server on an Ubuntu machine
on hosted on Azure. You will also gain familiarity with basic Linux commands, and you will
deploy a custom application that is accessible from the public Internet.

LearningObjectives

After completing the exercises in this lab, you will be able to:

Install basic applications on a Linux machine with an Ubuntu distribution running on


Azure.

Gain some basic knowledge on using Apache, MySQL, and PHP.

Have some experience in the steps required to deploy a LAMP application in a Linux
VM.


Estimated time to complete this lab: 30 mins



2016MicrosoftCorporation.Allrightsreserved.

DeployingOpenSourceSoftwareonMicrosoftAzureLabExercise

LabExercise

Task
CreateaLinuxServer

Task
ConnecttoyourLinuxvirtual
machineonAzurethroughanSSH
client.

Forthepurposesofthistutorial,we
aregoingtobeusingapopularSSH
clientcalledPuTTY.Itisafreeand
opensourceterminalemulatorthat
requiresnoinstallationandrunson
Windows,Linux,andOS_X.

DetailedSteps
1.

IntheAzureportal,createanewUbuntu14.04LTSserver.
Provideauniquename,username,passwordandresource
groupthatyoucanremember.Youmightwanttorecordthem
forlaterreference.Otherwise,acceptalldefaults.

2.

TheVMmustbeprovisionedwithapublicIPaddressinorder
tobeaccessiblefromthepublicInternet.Nofurther
connectivitybetweenVMsisrequired.

DetailedSteps

3.

FromServer1runthePuTTY.exefilethatisonthedesktop.

4.

UnderHostName,insertthepublicIPaddressofyourLinux
VMrunningonAzure.IfyouhaveconfiguredaDNSnamefor
yourVM(e.g.server1.eastus.cloudapp.azure.com),youmay
insertthatinstead.

5.

TheterminaloftheLinuxVMrunningonAzurewillappear,
promptingyouforyourVMsusernameandpassword.Type
thoseintofinishconnectingtoyourVMthroughanSSHclient.
Ifyouarepromptedtocachethekeyfingerprint,chooseYes.

2016MicrosoftCorporation.Allrightsreserved.

DeployingOpenSourceSoftwareonMicrosoftAzureLabExercise

Figure1:ThepublicIPaddressofyourVMcanbefoundhereontheAzureportal.

Figure2:TheLinuxterminaloftheVMrunningonAzure(left)andthehomepageofPuTTY
(right).UnderHostName,eithertheDNSnameofyourVMorthepublicIPaddressofthe
VMcanbeused.

Scenario:InstallandrunMySQL
In this scenario you will install MySQL and test it.

2016MicrosoftCorporation.Allrightsreserved.

DeployingOpenSourceSoftwareonMicrosoftAzureLabExercise

Task

DetailedSteps
PerformthefollowingonSERVER1(throughthe
terminaldisplayedbyyourSSHclient)

LoginasarootusertoyourLinuxVM.
Thisensuresthatthecommandsudodoesnotneed
tobeusedtorunothercommandsthatmightrequire
rootpermissions(similartoAdministratorprivileges
onaWindowsmachine).

1.

Runthecommandsudosu

2.

Runthecommandaptgetinstall
mysqlservermysqlclient
Youwillbepromptedaboutwhetherto
continuewiththeinstallation.EnterY
Youwillbepromptedforapassword
fortheMySQLrootuser.Typein
Pa$$word1
ReenterthesameMySQLrootuser
passwordasconfirmation.
Runthefollowingcommand(eitheras
arootuserorastheregularLabUser):
mysqlurootp
YouwillbepromptedfortheMySQL
passwordfortherootuser.Typein
Pa$$word1

3.
InstallMySQL5

4.

5.
6.
ConnecttoMySQL
7.

8.
Createandshowexampledatabase
9.

Runthecommandcreatedatabase
test_database;ontheMySQL
commandlineinterface(CLI).
Runthecommandshowdatabases;

2016MicrosoftCorporation.Allrightsreserved.

DeployingOpenSourceSoftwareonMicrosoftAzureLabExercise

Figure3:TheLinuxterminalafterrunningthecommandstoconnecttoMySQLandcreatea
newdatabase.Noticethatthenewdatabasecreated,test_database,appearsonthelist
ofdatabases.

DetailedSteps

Selectdatabasetoworkwith
Afterselectingwhichdatabasetoworkwith,all
operationssuchasqueryingdata,creatingnewtables,
andothertypicalMySQLcommandswilloperateonthis
database.

Deletethedatabase

1.

Runthecommandusetest_database;

2.

Runthecommand
dropdatabasetest_database;

3.

Runthecommandexit

ExitfromtheMySQLCLI
Afterrunningthiscommand,youwillreturntothe
terminalofyourLinuxVM.

Scenario:InstallandrunApache2
In this scenario you will install Apache and test it.

2016MicrosoftCorporation.Allrightsreserved.

DeployingOpenSourceSoftwareonMicrosoftAzureLabExercise

Task

DetailedSteps
PerformthefollowingstepsonSERVER1
(throughtheterminaldisplayedbyyourSSH
client):

1.
InstallApache2

2.

Runthecommandaptgetinstall
apache2
Whenpromptedforconfirmation,type
Y

Task

DetailedSteps

OnMicrosoftAzure,dothefollowing:

3.
ConfigureyourVMsNetworkSecurityGroup(NSG)to
allowinboundtrafficthroughport80andport8080.

Port80istheHTTPport,andport80isboththe
alternateHTTPportandthedefaultportusedby
Apache.

IfyourVMdoesnothaveanattachedNSG,all
inboundtrafficwillbeallowedbydefault,sothisstep
isnotnecessary.

4.
5.
6.

NavigatetoyourVMsNetwork
SecurityGroup(NSG)
ClickonSettings,thenonInbound
securityrules
ClickonAddtomakeanewNSGrule
Fillinthefollowingoptionsandthen
clickOK:
Name:allowHTTP
Priority:1100
Source:Any
Protocol:Any
SourcePortRange:*
Destination:Any
DestinationPortRange:80
Action:Allow

2016MicrosoftCorporation.Allrightsreserved.

DeployingOpenSourceSoftwareonMicrosoftAzureLabExercise

Figure4:TheoptionstonavigatethroughontheNSGassociatedwithyourVMtoaddanew
Inboundsecuritygroup.

Figure5:TheoptionsforthenewNSGruletoallowinboundtrafficonport80

2016MicrosoftCorporation.Allrightsreserved.

DeployingOpenSourceSoftwareonMicrosoftAzureLabExercise

7.
8.

ClickonAddagain
Fillinthefollowingoptionsandthen
clickOK:
Name:allowHTTPAlternate
Priority:1200
Source:Any
Protocol:Any
SourcePortRange:*
Destination:Any
DestinationPortRange:8080
Action:Allow


Task

DetailedSteps

LocalComputer

Onyourlocalcomputer(oranyothercomputer
thatisnotyourLinuxVM),dothefollowing
1.

AccessyourLinuxVMthroughthepublicInternet
throughApache.

Apache'sdefaultdocumentrootis/var/www/htmlon
Ubuntu

2.

3.

OpenyourpreferredInternetbrowser
(e.g.MicrosoftEdge,InternetExplorer,
MozillaFirefox,etc.)
NavigatetothepublicIPaddressof
yourVM(or,alternatively,theDNS
nameofyourVMifyouhavethat
configured).TheparticularVMusedin
thistutorialhappenstohavebeen
giventheaddress40.76.59.103
ObservethatthedefaultApache
welcomepageshouldappearasshown
inFigure6.

Figure6:ThedefaultApachewelcomepagethatappearswhenyounavigatetoyourVM's
publicIPaddressafterinstallingApache2.

2016MicrosoftCorporation.Allrightsreserved.

DeployingOpenSourceSoftwareonMicrosoftAzureLabExercise

Task

DetailedSteps
OnSERVER1(throughtheterminaldisplayedby
yourSSHclient),dothefollowing:

1.
TestyourApacheinstallationbyaccessingthedefault
ApachewelcomepagefromyourLinuxVM.

2.

1.
2.
3.
4.

ReplacethedefaultApachewelcomepagewithyour
owncustomHTMLpage.

5.

Runthecommandcurl
http://localhost/
YouwillseetheApache2Ubuntu
DefaultPagedisplayedasrawHTML
code.
NavigatetotheHTMLfolderofApache
byrunningcd/var/www/html/
Deletethedefaultindex.htmlfileby
runningrmfrindex.html
Openthevitexteditorbytypingvi
index.html
Youarenowinsidethefileindex.html
throughthevitexteditor.Typeinthe
followingHTMLcode:

<!DOCTYPEhtml>
<html>
<body>
<h1>TestHeading</h1>
<p>Testparagraph.</p>
</body>
</html>

EntertheEscbutton,thentypein:wq
andthentypetheEnterbuttoninorder
tosaveandclosethefile.

10

2016MicrosoftCorporation.Allrightsreserved.

DeployingOpenSourceSoftwareonMicrosoftAzureLabExercise

Figure7:Thevitesteditorshowingthenewlycreatedindex.htmlfile.Noticethatthe
bottomofthetexteditorshowsthe:wqcommand.UponpressingtheEnterbutton,thefile
willbesavedandclosed.
6.

7.

Navigatebacktotherootdirectoryof
yourLinuxVMbytypingcd/
Typeincurlhttp://localhost/
ThiswilldisplaytheHTMLpage(inraw
HTMLformat)thatyouwrotebefore.


Task

DetailedSteps
Onyourlocalcomputer(oranyothercomputer
thatisnotyourLinuxVM),dothefollowing

LocalComputer

8.
9.

OpenyourpreferredInternetbrowser
NavigatetothepublicIPaddressof
yourVM.TheparticularVMusedinthis
tutorialhappenstohavebeengiven
theaddress40.76.59.103
10. ObservethattheHTMLpagethatyou
previouslywroteisnowdisplayed.

AccessyourLinuxVMthroughthepublicInternet.

Scenario:InstallandrunPHP5
In this scenario you will install PHP and test it.
Task

DetailedSteps
OnSERVER1(throughtheterminaldisplayedby
yourSSHclient),dothefollowing:

11

2016MicrosoftCorporation.Allrightsreserved.

DeployingOpenSourceSoftwareonMicrosoftAzureLabExercise

Task
InstallPHP5

YoumightreceiveawarningduringtheApache
restartaboutnotbeingabletoidentifytheservers
fullyqualifieddomainname.Thiswarningcanbe
safelyignoredforthepurposesofthistutorial.

DetailedSteps
1.
2.
3.
4.

5.
TestyourPHP5installationbycreatinganewPHPfile
andnavigatingtoit.

6.

Runthecommandaptgetinstallphp5
libapache2modphp5
AcceptanyuserpromptsbytypingY
RestartApachebyrunningservice
apache2restart
CreateanewfileinthedefaultHTML
directorybytypingvi
/var/www/html/info.php
TypeinthefollowingPHPcodeinthevi
texteditor:

<?php
phpinfo();
?>

EntertheEscbutton,thentypein:wq
andthentypetheEnterbuttoninorder
tosaveandclosethefile.


Task

DetailedSteps

LocalComputer

Onyourlocalcomputer(oranyothercomputer
thatisnotyourLinuxVM),dothefollowing
7.
8.

AccessyourLinuxVMthroughthepublicInternet.
9.

OpenyourpreferredInternetbrowser.
NavigatetoyourVMspublicIPaddress
andthePHPfileyoujustsaved.Forthis
tutorialsVM,typein
http://40.76.59.103/info.php
ObservethedefaultPHPinformation
pagethatisgeneratedthroughthePHP
filepreviouslysaved.

Figure8:ThePHPinfopagedisplayedwhennavigatingtothenewlysavedPHPfile.

12

2016MicrosoftCorporation.Allrightsreserved.

DeployingOpenSourceSoftwareonMicrosoftAzureLabExercise

InstallMySQLsupportinPHP

Youcanalsoinstallothermodules,suchascURL
supportinPHP.YoucansearchforavailablePHP5
modulesbytypingaptcachesearchphp5

10. Runthecommandaptgetinstallphp5
mysql
11. RestartApachebyrunningservice
apache2restart

Scenario:Runacustomapplication(inparticularthe2048game)
In this scenario you will download a custom application (the 2048 game) and run it from your VM.
Task

DetailedSteps
PerformthefollowingstepsonSERVER1
(throughtheterminaldisplayedbyyourSSH
client):

1.

2.
Copytheapplicationcodeforthe2048gamefroma
publicGithubrepositoryintotheHTMLfolder

3.

4.

13

RemoveeverythingfromtheHTML
folderbytypingrmfr
/var/www/html
InstallGitbytypingthecommandapt
getinstallgit
ClonetheGitrepositoryintotheHTML
folderbytypinggitclone
https://github.com/gabrielecirulli/204
8.git/var/www/html
NavigatetoyourLinuxVMthroughthe
publicInternettoplaythe2048game
onyourbrowser(asshowninFigure9).

2016MicrosoftCorporation.Allrightsreserved.

DeployingOpenSourceSoftwareonMicrosoftAzureLabExercise

Figure9:The2048gamerunningfromyourLinuxVMonAzure.

14

2016MicrosoftCorporation.Allrightsreserved.

DeployingOpenSourceSoftwareonMicrosoftAzureUsefulLinks

UsefulLinks
UsingtheUbuntuterminal:https://help.ubuntu.com/community/UsingTheTerminal
MySQLtutorial:http://www.mysqltutorial.org

15

2016MicrosoftCorporation.Allrightsreserved.

Você também pode gostar