{"id":3792,"date":"2018-10-04T11:59:33","date_gmt":"2018-10-04T11:59:33","guid":{"rendered":"https:\/\/cloudkul.com\/blog\/?p=3792"},"modified":"2018-10-11T04:29:42","modified_gmt":"2018-10-11T04:29:42","slug":"lamp-installation-on-google-cloud","status":"publish","type":"post","link":"https:\/\/cloudkul.com\/blog\/lamp-installation-on-google-cloud\/","title":{"rendered":"LAMP installation on Google Cloud Platform"},"content":{"rendered":"<h2><strong>Introduction:<\/strong><\/h2>\n<p>&nbsp;<\/p>\n<p>In our <a href=\"https:\/\/cloudkul.com\/blog\/running-compute-engine-vm-on-google-cloud\/\">previous blog<\/a>, we discussed about how to create a compute engine VM on GCP. In this blog, we will discuss about LAMP installation with multi-tier architecture on GCP. We will be using the Compute Engine service of GCP for Linux server, Apache Web server and php. For the Mysql database, we will use the SQL service of GCP as a separate micro service. We will connect both the services to design\u00a0 a multi-tier architecture for LAMP installation. For Installing LAMP on GCP, you need to have a registered GCP account. For this blog, we assume that you already have a registered GCP account.<\/p>\n<p>&nbsp;<\/p>\n<h2><strong>Creating a Compute Engine VM:<\/strong><\/h2>\n<p>&nbsp;<\/p>\n<p>For creating a Compute engine VM, you may refer to my previous blog on <a href=\"https:\/\/cloudkul.com\/blog\/running-compute-engine-vm-on-google-cloud\/\">running a compute engine VM on GCP<\/a>. In this blog, we will use the following:<\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li>Linux OS: Ubuntu 16.04<\/li>\n<li>Apache Version: v2.4<\/li>\n<li>Mysql Version : v5.7<\/li>\n<li>Php Version: v7.0<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>First create a Compute Engine VM on your GCP account and once you have created a VM instance, ssh login to the VM server to install apache and php. You can login to ssh either via GCP provided web console or third-party ssh tools like terminal or putty. Here we will use the GCP web console for ssh login. For details on using third-party ssh tools, please refer to my<a href=\"https:\/\/cloudkul.com\/blog\/running-compute-engine-vm-on-google-cloud\/\"> previous blog<\/a>.<\/p>\n<p>&nbsp;<\/p>\n<p>To SSH login to the VM instance via &#8220;ssh web interface&#8221;, click on the SSH button of the instance from the console by going to Navigation menu &gt; Compute Engine &gt; VM Instances. On clicking on the ssh button of the VM instance, an ssh web interface will be prompt where\u00a0 you will be logged in to that particular instance. Here you can perform any operations on the server via ssh.<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2018\/10\/gcp-ssh2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3803\" src=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2018\/10\/gcp-ssh2.png\" alt=\"\" width=\"1089\" height=\"271\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<h2><strong>Installing Apache and PHP:<\/strong><\/h2>\n<p>&nbsp;<\/p>\n<p>After login into the VM instance, you can install apache web server and PHP. You can define your preferred php version for installation.<\/p>\n<p>To install apache web server, Use the following commands.<\/p>\n<pre class=\"lang:default decode:true\">sudo apt-get -y install apache2<\/pre>\n<p>&nbsp;<\/p>\n<p>To install php and its extensions, use the bellow commands. We will use php7.0 for the demo.<\/p>\n<pre class=\"lang:default decode:true\">sudo locale-gen en_US.UTF-8\r\nexport LANG=en_US.UTF-8\r\nsudo apt-get update\r\nsudo apt-get install -y software-properties-common python-software-properties\r\nsudo LC_ALL=en_US.UTF-8 add-apt-repository -y ppa:ondrej\/php\r\nsudo apt-get update\r\napt-get -y install php7.0 php7.0-curl php7.0-bcmath php7.0-intl php7.0-gd php7.0-dom php7.0-mcrypt php7.0-iconv php7.0-xsl php7.0-mbstring php7.0-ctype php7.0-zip php7.0-pdo php7.0-xml php7.0-bz2 php7.0-calendar php7.0-exif php7.0-fileinfo php7.0-json php7.0-mysqli php7.0-mysql php7.0-posix php7.0-tokenizer php7.0-xmlwriter php7.0-xmlreader php7.0-phar php7.0-soap php7.0-mysql php7.0-fpm libapache2-mod-php7.0\r\nsed -i -e\"s\/^memory_limit\\s*=\\s*128M\/memory_limit = 512M\/\" \/etc\/php\/7.0\/apache2\/php.ini<\/pre>\n<p>&nbsp;<\/p>\n<p>To check apache and php installations and its version, use the below command.<\/p>\n<pre class=\"lang:default decode:true\">apache2 -v\r\nphp -v<\/pre>\n<p>&nbsp;<\/p>\n<p>Enable apache rewrite and headers module.<\/p>\n<pre class=\"lang:default decode:true \">sudo a2enmod rewrite\r\nsudo a2enmod headers\r\nsudo service apache2 restart<\/pre>\n<p>&nbsp;<\/p>\n<p>Now Apache webserver and php has been installed on your server.<\/p>\n<p>Further you may also need to install mysql-client to login to the remote database instance i.e. on SQL service of GCP.<\/p>\n<p>To install mysql-client, use the below command.<\/p>\n<pre class=\"lang:default decode:true \">sudo apt-get -y install mysql-client<\/pre>\n<p>&nbsp;<\/p>\n<p>To check the mysql installation and its version, use the below command.<\/p>\n<pre class=\"lang:default decode:true \">mysql --version<\/pre>\n<p>&nbsp;<\/p>\n<h2><strong>Creating a MySQL database using SQL service of GCP:<\/strong><\/h2>\n<p>&nbsp;<\/p>\n<p>To create a mysql database using SQL service of GCP, go to Navigation menu\u00a0 &gt; SQL. Now click on &#8220;create instance&#8221;, choose database engine as MySQL and click on next. Next you need to choose the use case i.e. for development, staging or production. Here we will choose development. Next in the configure step,\u00a0 choose Instance Id, Root Password, Region and zone. You can also change other configuration parameters as per your requirement but we will keep it default for this demo. Now click on create button to create the mysql instance. Once the Mysql Instance is created, you can click on its instance id to see its details. You can also find the Public IP of the MySQL instance in the Overview section.<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2018\/10\/gcp-mysql.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3807\" src=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2018\/10\/gcp-mysql.png\" alt=\"\" width=\"888\" height=\"279\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<h2><strong>Connecting MySQL Database with VM instance:<\/strong><\/h2>\n<p>&nbsp;<\/p>\n<p>Once you have created a Mysql Database on SQL service of GCP, its time to connect the Database to the Compute Engine VM instance. For this, you need to allow the public IP of the Compute VM, in the firewall rules of the MySQL service. Click on the MySQL database Instance Id that you created and select the Connections Tab, and under the connectivity section, click on &#8220;Add network&#8221;. Now give a name to the network and add the IP of the Compute VM instance in the CIDR format i.e. &lt;ipv4_address&gt;\/32 and finally click on done and save. This will allow the Compute VM instance to connect with the MySQL database instance.<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2018\/10\/gcp-add_network2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3805\" src=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2018\/10\/gcp-add_network2.png\" alt=\"\" width=\"649\" height=\"474\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>To verify that the database is properly authenticated to the MySQL database, ssh login to the Compute VM instance and check if you are connected and able to login to the database instance. For this you need the Public IP of the database instance which you can easily get in the overview section of the MySQL Instance.<\/p>\n<pre class=\"lang:default decode:true\">ping  &lt;public_IP_of_MySQL_instance&gt;<\/pre>\n<pre class=\"lang:default decode:true \">mysql -h &lt;public_IP_of_MySQL_instance&gt; -u root -p<\/pre>\n<p>&nbsp;<\/p>\n<p>If you are able to login to the MySQL instance through the public IP, then your Compute instance VM is properly authenticated the MySQL database instance.<\/p>\n<p>&nbsp;<\/p>\n<p>Congrats, you have now successfully set up LAMP on GCP with multi-tier architecture with separate Instance for Compute and Database.<\/p>\n<p>Stay Connected!<\/p>\n<p>&nbsp;<\/p>\n<p><strong><em>In case of any help or query, please\u00a0<a href=\"http:\/\/cloudkul.com\/contact\/\" target=\"_blank\" rel=\"noopener noreferrer\">contact us<\/a><\/em><em> or raise a ticket at <a href=\"mailto:support@webkul.com\">support@webkul.com<\/a>.<\/em><em><br \/>\n<\/em><\/strong><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction: &nbsp; In our previous blog, we discussed about how to create a compute engine <a class=\"text-primary\" title=\"read more\" href=\"https:\/\/cloudkul.com\/blog\/lamp-installation-on-google-cloud\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":19,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[2,86,21],"tags":[203],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>LAMP installation on Google Cloud Platform - Cloudkul<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/cloudkul.com\/blog\/lamp-installation-on-google-cloud\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"LAMP installation on Google Cloud Platform - Cloudkul\" \/>\n<meta property=\"og:description\" content=\"Introduction: &nbsp; In our previous blog, we discussed about how to create a compute engine [...]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/cloudkul.com\/blog\/lamp-installation-on-google-cloud\/\" \/>\n<meta property=\"og:site_name\" content=\"Cloudkul\" \/>\n<meta property=\"article:published_time\" content=\"2018-10-04T11:59:33+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-10-11T04:29:42+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2018\/10\/gcp-ssh2.png\" \/>\n<meta name=\"author\" content=\"Kamal Verma\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/cloudkul.com\/blog\/lamp-installation-on-google-cloud\/\",\"url\":\"https:\/\/cloudkul.com\/blog\/lamp-installation-on-google-cloud\/\",\"name\":\"LAMP installation on Google Cloud Platform - Cloudkul\",\"isPartOf\":{\"@id\":\"https:\/\/cloudkul.com\/blog\/#website\"},\"datePublished\":\"2018-10-04T11:59:33+00:00\",\"dateModified\":\"2018-10-11T04:29:42+00:00\",\"author\":{\"@id\":\"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/06c6ea4ff7ba3c7c066fa1ee606bf051\"},\"breadcrumb\":{\"@id\":\"https:\/\/cloudkul.com\/blog\/lamp-installation-on-google-cloud\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/cloudkul.com\/blog\/lamp-installation-on-google-cloud\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/cloudkul.com\/blog\/lamp-installation-on-google-cloud\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/cloudkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"LAMP installation on Google Cloud Platform\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/cloudkul.com\/blog\/#website\",\"url\":\"https:\/\/cloudkul.com\/blog\/\",\"name\":\"Cloudkul\",\"description\":\"Host your eCommerce Store on AWS with Optimized Performance\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/cloudkul.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/06c6ea4ff7ba3c7c066fa1ee606bf051\",\"name\":\"Kamal Verma\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/63cc4ebeffa54b7ceb9b2d552926f2f6?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/63cc4ebeffa54b7ceb9b2d552926f2f6?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g\",\"caption\":\"Kamal Verma\"},\"url\":\"https:\/\/cloudkul.com\/blog\/author\/kamaldev-cloudkul308\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"LAMP installation on Google Cloud Platform - Cloudkul","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/cloudkul.com\/blog\/lamp-installation-on-google-cloud\/","og_locale":"en_US","og_type":"article","og_title":"LAMP installation on Google Cloud Platform - Cloudkul","og_description":"Introduction: &nbsp; In our previous blog, we discussed about how to create a compute engine [...]","og_url":"https:\/\/cloudkul.com\/blog\/lamp-installation-on-google-cloud\/","og_site_name":"Cloudkul","article_published_time":"2018-10-04T11:59:33+00:00","article_modified_time":"2018-10-11T04:29:42+00:00","og_image":[{"url":"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2018\/10\/gcp-ssh2.png"}],"author":"Kamal Verma","twitter_card":"summary_large_image","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/cloudkul.com\/blog\/lamp-installation-on-google-cloud\/","url":"https:\/\/cloudkul.com\/blog\/lamp-installation-on-google-cloud\/","name":"LAMP installation on Google Cloud Platform - Cloudkul","isPartOf":{"@id":"https:\/\/cloudkul.com\/blog\/#website"},"datePublished":"2018-10-04T11:59:33+00:00","dateModified":"2018-10-11T04:29:42+00:00","author":{"@id":"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/06c6ea4ff7ba3c7c066fa1ee606bf051"},"breadcrumb":{"@id":"https:\/\/cloudkul.com\/blog\/lamp-installation-on-google-cloud\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/cloudkul.com\/blog\/lamp-installation-on-google-cloud\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/cloudkul.com\/blog\/lamp-installation-on-google-cloud\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/cloudkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"LAMP installation on Google Cloud Platform"}]},{"@type":"WebSite","@id":"https:\/\/cloudkul.com\/blog\/#website","url":"https:\/\/cloudkul.com\/blog\/","name":"Cloudkul","description":"Host your eCommerce Store on AWS with Optimized Performance","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/cloudkul.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/06c6ea4ff7ba3c7c066fa1ee606bf051","name":"Kamal Verma","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/63cc4ebeffa54b7ceb9b2d552926f2f6?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/63cc4ebeffa54b7ceb9b2d552926f2f6?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g","caption":"Kamal Verma"},"url":"https:\/\/cloudkul.com\/blog\/author\/kamaldev-cloudkul308\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts\/3792"}],"collection":[{"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/users\/19"}],"replies":[{"embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/comments?post=3792"}],"version-history":[{"count":29,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts\/3792\/revisions"}],"predecessor-version":[{"id":3874,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts\/3792\/revisions\/3874"}],"wp:attachment":[{"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/media?parent=3792"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/categories?post=3792"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/tags?post=3792"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}