Post on 17-Feb-2017
What’sCoveredWhat’sCoveredSlide Topic3 Introduction4 IaaS vs.PaaSvs.SaaS5 ArchitectureOverview7 Part One– CreateaComputeEngineinstance11 Part Two– ConfigureComputeEngine15 PartThree– CreateaCloudSQLinstance24 PartFour– InstallandConfigure WordPress30 NowWhat?
IntroductionIntroduction
ThepurposeofthistutorialisnotonlytoinstallWordPressbuttolearnmoreabouttheGoogleCloudPlatformConsole.Inaddition,learnhowtousesomeoftheresourcessuchasComputeEngineandCloudSQL.
ThiswillgiveyouagoodbasicunderstandingofGoogle’scloudoffering.
InfrastructureasaService(IaaS) PlatformasaService(PaaS) SoftwareasaService(SaaS)
IaaSvs.PaaSvs.SaaSIaaSvs.PaaSvs.SaaS
AssembleandconfigurethevariousresourcesofComputeEngine,CloudSQLandCloudStoragetorunWordPress.
InstallWordPressonAppEngineandlettheprovisioningofresourceshappeninthebackground.
VisitWordPress.comandstartbloggingwithoutconfiguring,installingormaintainingWordPresssoftware.
ComputeEngine
CloudSQL
CloudStorage
AppEngine
ArchitectureOverviewArchitectureOverview
UsersInternet
Region:asia-east1(Taiwan)
Zone:asia-east1-a
ComputeEngine
CloudSQL
CloudStorage
PartOne:PartOne:CreateaComputeEngineInstanceCreateaComputeEngineInstance
Incloud-speakcreatinganewvirtualserveriscalledan“instance”.“Spinningupaninstance”isaphraseyouwillhearquiteoftenwhichjustreferstostartinganewComputeEngineinstance.
PartTwo:PartTwo:ConfigureYourComputeEngineInstanceConfigureYourComputeEngineInstance
NowthattheComputeEngineinstancehasbeencreatedit’stimetoinstalltheLEMP(Linux,Nginx,MySQLandPHP)stackwhichwe’llneedbeforeyoucaninstallWordPress.TheLinuxkernelwaspreinstalledwhentheinstancewascreated.Nginx andPHPwillbeinstalledinthissection.MySQLwillbeinstalledinthenextsection.
Step1:ConnecttotheComputeEngineinstance
Therearemultiplewaystoconnecttotheinstance:• FromtheGCPConsoleclickonSSHnexttotheinstancename• FromtheGoogleCloudShell• UsingSSHfromaterminalwindow• UsingCloudSDKCLIfromaterminalwindow
Touseyour terminalwindow,download theGCPCloudSDKandfollowtheinstructions toinstallit.Thenclickon“Viewglcloud command”andenterthatinyourterminalwindow.
gcloud compute --project ”Name of your project" ssh --zone "asia-east1-a" ”your instance name"
Step2:InstallNginx , PHPandMySQL
Onceconnectedtotheinstance,switchtosuperuser:sudo su
Installanynewupdates:apt-get update
InstallNginx , PHPandMySQLextension:apt-get install -y nginx php5-fpm php5-mysql mysql-client
Step3:EdittheNginx configurationfile
EdittheNginx config filetoallowindex.php asadefaultfiletoload:nano /etc/nginx/sites-available/default
Add index.php tothelinebelow:index index.php index.html index.htm;
Uncommentthefollowing lines:location ~ \.php$ { try_files $uri =404; # fastcgi_split_path_info ^(.+\.php)(/.+)$; # # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini# # With php5-cgi alone: # fastcgi_pass 127.0.0.1:9000;# With php5-fpm: fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; }
[ControlX tosave,thenY,thenEnter]
PartThree:PartThree:CreateaCloudSQLInstanceCreateaCloudSQLInstance
InsteadofrunningMySQLonthesameComputeEngineinstancewewilluseCloudSQLtorunthedatabaseonaseparateserver.
Step8:UsetheCloudSDKcommandlinetocreateadatabaseona2nd Geninstance
Connect to the Compute Engine instance, then type the following to connect to the Cloud SQL instance:mysql --host=<IP address of Cloud SQL> --user=root --password
At the mysql prompt:CREATEDATABASEwordpress;
Step1:DownloadandInstallWordPress
Change to the root directory of Nginx:cd /usr/share/nginx/html
Download the latest WordPress package:wget http://wordpress.org/latest.tar.gz
Extract WordPress:tar -xzvf latest.tar.gz
Move WordPress to the default root folder: (rsync keeps the permissions)rsync -avP /usr/share/nginx/html/wordpress/ /usr/share/nginx/html/
Delete the WordPress tar filerm latest.tar.gz
Change permissions on the directory:chown -hR www-data:www-data /usr/share/nginx/htmlchmod -R g+rw /usr/share/nginx/html
Restart the Nginx serverservice nginx restart
NowWhat?NowWhat?
MakethingsandbreakthingstolearnhowallthevariousservicesofGCPworktogether.
VisitGCPformoretutorialsat:https://cloud.google.com/docs/
ConnectingtoCloudSQLviaComputeEngineoverSSH(usingMySQLWorkbench)
IPaddressofComputeEngine
IPaddressofCloudSQL
Username