The Google Cloud Engine lets you create flexible virtual machines and run them on the high performing Google infrastructure.
In this article, I'll walk you through the process of installing Drupal 7 on a Google Cloud virtual machine instance. I'm writing this article because Google Cloud has a great variety of tools for 1-click installs. Though they do not have a Drupal 7 install, and their 1-click LAMP install uses a more expensive box than required. This article outlines the steps required to create a LAMP install on their base performance instance along with drush and Drupal 7.
- Create a Google Cloud account.
Setting up the first virtual machine (VM)
Log onto your Google Cloud account and navigate to the console page.
Go to "compute engine" then "create new VM".
Pick a VM with Debian 8.
- The basic VM CPU can run Drupal with ease.
Make sure to check both firewall options.
Logging into your new VM instance
There are 2 ways to go about logging into your VM.
The 1st way is to log in from within the browser console "<img>" that Google Cloud provides.
The 2nd way is to ssh in from your local terminal window which requires the following steps:
- Open your local terminal window and enter the following command:
ssh-keygen -t rsa -f ~/.ssh/your-key-name -C <google cloud user name>
- If you don't know your username, ssh into the VM using the browser window Google provides.
- Follow the instructions for setting up "public key" in terminal.
- Copy the output.
- It should be in the format of "ssh-rsa<key><username>"
- On Google Cloud Console platform go to -> metadata ->ssh keys.
- Add a new key and paste your key into the new field.
- You should now be able to ssh into your new box now.
ssh <username>@<VM IP>
Now you should be logged into your VM instance.
Setup LAMP on your new VM box
Start with Apache and enter the following commands:
sudo apt-get update sudo apt-get install apache2
To see if that worked, go to your ip located on the VM instance page.
You should see a page that reads "Acpache2 Debian Default Page".
sudo apt-get install mysql-server php5-mysql
Give root use a password.
sudo mysql_install_db sudo /usr/bin/mysql_secure_installation
This step is important to safely secure your MySQL installation by setting the root password, removing the anonymous user, restricting root user access, and removing the test database.
Verify thatMySQLl is installed.
mysql -uroot -p
Provide the password you created above.
Create the Drupal database
mysql -uroot -p
- This will prompt you for the password you just created for root user in MySQL.
CREATE database drupal;
Now for a more secure site, let's create a user for this newly created database.
CREATE user '[newUser]'@'localhost' IDENTIFIED BY '[password]';
GRANT ALL PRIVILEGES on drupal.* to ‘[newUser]’@‘localhost’;
Step 1: Enter the following commands:
sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt phpmyadmin sudo apt-get install php5-gd
Step 2: Test the newly installed PHP
The following commands will reload Apache and test the PHP.
sudo /etc/init.d/apache2 reload sudo rm /var/www/html/index.html sudo vim /var/www/html/index.php
This will open your VIM editor where you should enter the following line. To begin typing in Vim hit the letter 'a'.
<?php phpinfo(); ?>
Closs and save the file (in vim, ZZ).
Go to your sites IP again and you should now see this PHP info page.
Installing Drupal 7
Step 1: Install Drush
This can be done in multiple ways. The steps below are from Drush docs.
php -r “readfile(‘http://files.drush.org/drush.phar');” > drush
- Manually type this if there's a token error.
chmod +x drush sudo mv drush /usr/local/bin drush init
Close and open your terminal window and test Drush.
Step 2: Install Drupal directory
Enter the following commands:
cd /var/www sudo rm html/index.php sudo drush dl drupal --default-major=7 --destination=. --drupal-project-rename=html Step 3: Install Drupal cd html sudo drush si standard --account-name=admin --account-pass=admin --db-url=mysql://[mysqluser]:[password]@localhost/[tablename] --clean-url
Now you have a working Drupal 7 install
But you're not done, you still need to secure your admin login. After your first login, please change the admin login from admin/admin to a secure password.