Setting up Drupal on Google Compute Engine
- Setting up the virtual machine
- Installing Drush
- Downloading Drupal
- Running the installer
- Viewing your Drupal site
- Sending email from Drupal
Setting up the virtual machine
You can also automatically deploy Drupal on your virtual machine by using the Cloud Launcher or you can use the remaining steps to install Drupal yourself.
After your virtual machine instance is up and running, use the Google Cloud Platform Console to connect over SSH.
Drush, the Drupal shell utility, simplifies installation and administration of Drupal. Use the following steps to install Drush:
Move the file:
chmod +x drush.phar sudo mv drush.phar /usr/local/bin/drush
Drush can download Drupal for you. Follow these steps:
Change directory to the web server root directory:
Remove the index file:
sudo rm index.html
Download Drupal by using Drush:
sudo drush dl drupal
Drush downloads the latest version. To learn how to download a specific version,
see the help for Drush:
Moving the files to the web server's root directory
Drush puts the Drupal files in a subdirectory that uses the format
VERSION represents the Drupal version number. You
probably don't want that directory name in your website path.
Move the files up one level in the directory structure. Note that the version number appears twice.
sudo mv drupal-/* drupal-/.htaccess ./
For Drupal 7, add:
sudo mv drupal-/.gitignore ./
Remove the now-empty directory:
sudo rm -rf drupal-/
Running the installer
Drush runs the installer for you. You must provide the following information:
- The password of the MySQL administrator that you provided before deploying the LAMP stack.
- An account name and password for the first Drupal user (the administrator).
- A name and user account information for the MySQL database.
Use the following command:
sudo drush site-install \ --db-su=root \ --db-su-pw=MYSQL_ADMIN_PASSWORD \ --account-name=NAME \ --account-pass=PASSWORD \ --site-name="Drupal on Google Compute Engine" \ --db-url=mysql://MYSQL_USERNAME:MYSQL_PASSWORD@localhost/DATABASE_NAME
DATABASE_NAME with the appropriate values.
Updating directory settings
You will need to set the Drupal
files directory to be writeable by the web
server by updating its permissions and ownership.
Change the permissions for the
sites/default/filesdirectory, as follows:
sudo chmod o+w sites/default/files
If you find that the directory doesn't already exist, simply create a new directory named
sites/default/and then change its permissions.
Change the ownership of the web server root directory so that Apache can access files:
sudo chown -RL www-data:www-data /var/www
Viewing your Drupal site
To view your Drupal site in a browser, first open port 80 to allow HTTP traffic to your server. Follow these steps:
- View your virtual machine instances in the Compute Engine instances page.
- In the External IP column, click the external IP address for your Drupal server name.
- In the dialog box that opens, select the Allow HTTP traffic check box.
- Click Apply to close the dialog box.
After completing these steps, you can click the external IP address link or enter it in the address bar to open your Drupal site's home page in your browser.
To log in to your site, use the Drupal administrator user name and the Drupal administrator password that you provided in the Drush installation command.
Sending email from Drupal
Google Compute Engine doesn't allow outbound connections on ports 25, 465, and 587. To send email from your instances, you must use a partner service, such as SendGrid. SendGrid offers customers of Google Compute Engine free or paid packages with costs that vary by monthly email volume.
Getting a SendGrid account
Use SendGrid's Google partner page to create an account. Note that Google will be compensated for customers who sign up for a paid package.
For more details about sending email, see Sending Email from an Instance.
Installing the SMTP Authentication Support module on Drupal
You must install the SMTP Authentication Support module to enable Drupal to send email.
- From the Downloads section of the SMTP Authentication Support page, copy the link address for the module. For example, in the Recommended releases table, right-click the link to tar.gz for the latest release and then copy its address.
- Log in to Drupal as the administrator.
- In Drupal, on the Modules page, click Install new module.
- In the Install from a URL text box, paste the URL that you copied.
- Click Install.
- After the installation completes, browse to the Modules page.
- Scroll to the bottom of the page. In the Mail section, select Enabled.
- Click Save configuration.
Configuring the module to use SendGrid
Now that the SMTP Authentication Support module is installed, provide the settings that connect it to your SendGrid account.
- In Drupal, on the Modules page, locate the SMTP Authentication Module row and then click Configure. The Configuration page opens.
- In Install options, turn the module on.
- In SMTP server settings, enter the following settings:
- SMTP server:
- SMTP port:
- SMTP server:
- In SMTP authentication, enter the username and password that you provided when you set up your SendGrid account.
- In E-mail options, enter the address and name that you want email to come
from. Note that if you don't provide these values, your e-mail will use
your Drupal site name and have an address similar to
firstname.lastname@example.org. These values might cause spam filters to intercept the messages.
Sending a test email
You can send an email from Drupal to test your SendGrid integration.
- On the Configuration page for the SMTP Authentication Module, select Enable debugging. This setting lets you see all of the messages about activity as your email is being sent.
- In Send test e-mail, enter the email address that you want to send the test email to.
- Click Save configuration to send the email.
If sending the email fails, log in to SendGrid website and verify that your SendGrid account is active. It's possible that activating the account can take some time. You can also check SendGrid's email activity page to see whether your email was blocked for some reason.