Top Banner
Installing WordPress on Google Cloud Platform (GCP) April 2016
35

Installing WordPress on Google Cloud Platform (GCP)

Feb 17, 2017

Download

Technology

Manish Jain
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Installing WordPress on Google Cloud Platform (GCP)

InstallingWordPressonGoogleCloudPlatform(GCP)

April2016

Page 2: Installing WordPress on Google Cloud Platform (GCP)

What’sCoveredWhat’sCoveredSlide Topic3 Introduction4 IaaS vs.PaaSvs.SaaS5 ArchitectureOverview7 Part One– CreateaComputeEngineinstance11 Part Two– ConfigureComputeEngine15 PartThree– CreateaCloudSQLinstance24 PartFour– InstallandConfigure WordPress30 NowWhat?

Page 3: Installing WordPress on Google Cloud Platform (GCP)

IntroductionIntroduction

ThepurposeofthistutorialisnotonlytoinstallWordPressbuttolearnmoreabouttheGoogleCloudPlatformConsole.Inaddition,learnhowtousesomeoftheresourcessuchasComputeEngineandCloudSQL.

ThiswillgiveyouagoodbasicunderstandingofGoogle’scloudoffering.

Page 4: Installing WordPress on Google Cloud Platform (GCP)

InfrastructureasaService(IaaS) PlatformasaService(PaaS) SoftwareasaService(SaaS)

IaaSvs.PaaSvs.SaaSIaaSvs.PaaSvs.SaaS

AssembleandconfigurethevariousresourcesofComputeEngine,CloudSQLandCloudStoragetorunWordPress.

InstallWordPressonAppEngineandlettheprovisioningofresourceshappeninthebackground.

VisitWordPress.comandstartbloggingwithoutconfiguring,installingormaintainingWordPresssoftware.

ComputeEngine

CloudSQL

CloudStorage

AppEngine

Page 5: Installing WordPress on Google Cloud Platform (GCP)

ArchitectureOverviewArchitectureOverview

UsersInternet

Region:asia-east1(Taiwan)

Zone:asia-east1-a

ComputeEngine

CloudSQL

CloudStorage

Page 6: Installing WordPress on Google Cloud Platform (GCP)

GetaFreeTrialGCPAccount@https://cloud.google.com/

Page 7: Installing WordPress on Google Cloud Platform (GCP)

PartOne:PartOne:CreateaComputeEngineInstanceCreateaComputeEngineInstance

Incloud-speakcreatinganewvirtualserveriscalledan“instance”.“Spinningupaninstance”isaphraseyouwillhearquiteoftenwhichjustreferstostartinganewComputeEngineinstance.

Page 8: Installing WordPress on Google Cloud Platform (GCP)

Step1:FromtheGCPConsole,clickonComputeEngine

Page 9: Installing WordPress on Google Cloud Platform (GCP)

Step2:ClickonCreateInstance

Page 10: Installing WordPress on Google Cloud Platform (GCP)

Step3:Enterinthedetails

Page 11: Installing WordPress on Google Cloud Platform (GCP)

PartTwo:PartTwo:ConfigureYourComputeEngineInstanceConfigureYourComputeEngineInstance

NowthattheComputeEngineinstancehasbeencreatedit’stimetoinstalltheLEMP(Linux,Nginx,MySQLandPHP)stackwhichwe’llneedbeforeyoucaninstallWordPress.TheLinuxkernelwaspreinstalledwhentheinstancewascreated.Nginx andPHPwillbeinstalledinthissection.MySQLwillbeinstalledinthenextsection.

Page 12: Installing WordPress on Google Cloud Platform (GCP)

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"

Page 13: Installing WordPress on Google Cloud Platform (GCP)

Step2:InstallNginx , PHPandMySQL

Onceconnectedtotheinstance,switchtosuperuser:sudo su

Installanynewupdates:apt-get update

InstallNginx , PHPandMySQLextension:apt-get install -y nginx php5-fpm php5-mysql mysql-client

Page 14: Installing WordPress on Google Cloud Platform (GCP)

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]

Page 15: Installing WordPress on Google Cloud Platform (GCP)

PartThree:PartThree:CreateaCloudSQLInstanceCreateaCloudSQLInstance

InsteadofrunningMySQLonthesameComputeEngineinstancewewilluseCloudSQLtorunthedatabaseonaseparateserver.

Page 16: Installing WordPress on Google Cloud Platform (GCP)

Step1:FromtheGCPConsole,clickonSQL

Page 17: Installing WordPress on Google Cloud Platform (GCP)

Step2:ClickonCreateInstance

Page 18: Installing WordPress on Google Cloud Platform (GCP)

Step3:ClickonChooseSecondGeneration

Page 19: Installing WordPress on Google Cloud Platform (GCP)

Step4:Selecttheoptionsthencreatetheinstance

Page 20: Installing WordPress on Google Cloud Platform (GCP)

Step5:ClickontheInstanceIDthatwasjustcreated

Page 21: Installing WordPress on Google Cloud Platform (GCP)

Step6:Clickon“Additem”toaddtheIPaddressoftheComputeEnginethatyoucreated

Page 22: Installing WordPress on Google Cloud Platform (GCP)

Step7:ClickonUsers,tochangetherootpassword

Page 23: Installing WordPress on Google Cloud Platform (GCP)

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;

Page 24: Installing WordPress on Google Cloud Platform (GCP)

PartFour:PartFour:InstallandConfigureWordPressInstallandConfigureWordPress

Page 25: Installing WordPress on Google Cloud Platform (GCP)

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

Page 26: Installing WordPress on Google Cloud Platform (GCP)

Step2:PointyourbrowsertotheIPaddressoftheComputeEngine,thenselectthelanguage

Page 27: Installing WordPress on Google Cloud Platform (GCP)

Step3:EntertheMySQLdetails

Page 28: Installing WordPress on Google Cloud Platform (GCP)

Step4:EntertheWordPressdetails

Page 29: Installing WordPress on Google Cloud Platform (GCP)

Step5:VisittheIPAddressoftheComputeEngine.Theblogislive!

Page 30: Installing WordPress on Google Cloud Platform (GCP)

NowWhat?NowWhat?

MakethingsandbreakthingstolearnhowallthevariousservicesofGCPworktogether.

VisitGCPformoretutorialsat:https://cloud.google.com/docs/

Page 31: Installing WordPress on Google Cloud Platform (GCP)

CreatedByCreatedBy

[email protected]

http://celestri.org

Page 32: Installing WordPress on Google Cloud Platform (GCP)

AppendixAppendix

Page 33: Installing WordPress on Google Cloud Platform (GCP)

ConnectingtoCloudSQLviaComputeEngineoverSSH(usingMySQLWorkbench)

IPaddressofComputeEngine

IPaddressofCloudSQL

Username

Page 34: Installing WordPress on Google Cloud Platform (GCP)

UsingCyberduck toTransferFilestoGoogleCloudStorage– Step1

Page 35: Installing WordPress on Google Cloud Platform (GCP)

UsingCyberduck toTransferFilestoGoogleCloudStorage– Step2