German version available here / Deutsche Version hier: Wie man sich einen Webserver bei Google Cloud Platform zulegt
What’s our goal
This is a two part series on using Google Cloud Platform (GCP). The goal of the first part is to get a web server started with least possible configuration effort. The result will be a configured server accessible at a static IP, working PHP and MySQL, and a static welcome page. As you can see, you will get a full-fledged LAMP stack out of the box. The second part is for all tech-savvy users not strangers to SSH and public/private key generation: We will configure a SSH connection to transfer all kinds of files to the server.
Register at GCP
To keep our 600-seconds-promise, let’s get going! But first things first: To get started, go to https://cloud.google.com/, click on one of the many „Free Trial“ buttons and fill out the registration form. This is one of the most complex tasks of this tutorial. Promised! The fields to enter consist of the usual personal and business data, your credit card number is for account validation only. Google emphasizes that billing will not start automatically, but you will explicitly be asked to continue when your free trial ends.
After registration you will be able to log into Google Developer Console immediately. There you will be asked to start a project and a billing account. The project is basically a name to assign your virtual machines to. If you skip the project setup, you can do so when you setup the web server.
Choose server software
The easiest way to continue is to go to the so called Google Cloud Launcher where you can choose the software components to deploy. All available 120+ components are listed but also subsetted in tabs. Click the Infrastructure tab to see, among other compnents, two different versions of the LAMP stack. The first is provided by Bitnami Solutions, the second one originates by „Google Click to Deploy Solution“. The latter contains information on the available components. As of time of writing, this is Apache 2.2, PHP 5.4 and MySQL 5.5. This is a bit outdated – especially with PHP 7 and MySQL 7 on their way to be released this year. But still not bad for a free trial period.
Configuration and Deployment
Start your setup by clicking the „Getting started“ button on the latter version. Assign your resource to your project and your billing account and hit „Continue“. If no project has been created so far, you have to do so right now. Initialization starts immidiately and takes some time.
Next, you get the chance to resize your virtual machine if necessary. Start by selecting a geographic zone nearby. The physical distance between your users browser and the server still effects the speed of web content delivery. So make sure you do not choose a zone at the other end of the world. Next choose how much power your VM should have. We chose a small instance with 1CPU and 1.7GB of RAM in the screenshot. But be free to upsize or downsize as needed. Furthermore configure disk type, space and whether to install phpmyadmin (advised) and continue. Deploying takes some time.
What to do next
Congratulations, that’s it! You are presented a resulting summary. Easy, wasn’t it? Before freaking out and advancing to your welcome page, take some time to take a look at the „What to do next“ section. Your web server is not publicly accessible yet. So follow at least the first advised step to some of open the HTTP port to the server. Furthermore note the MySQL/PHPMyAdmin user name and password (change this later), and the External IP.
Todays reward will be a welcome page saying „It works!“ as soon as you open a new browser tab and enter to external IP address of your virtual machine. Well done!
Your web server will keep running until your free trial ends or you manually shut it down using the Google Developer Console. You can also use the console to manage your server, simple choose Compute > Compute Engine > VM Instances from the left side menu.