Deploy Drupal with Amazon RDS

TUTORIAL

Module 4: Configuring Drupal on EC2

Set up your Drupal installation to make it live

Overview

In the previous modules, you performed a number of configuration steps for your Drupal site. You created both an RDS database instance and an EC2 server instance. You configured your RDS instance to allow network access from your EC2 instance. Finally, you learned how to SSH into your EC2 instance using AWS Systems Manager Session Manager and configured a database user to be used by Drupal.

In this module, you will set up your Drupal installation to make it live. In the steps below, you will configure a web server, download the Drupal code, and configure your Drupal settings. At the end of this module, you will have a live Drupal site that you can access from your web browser.

To complete the steps in this module, you will need to connect into your EC2 instance. Please review the steps in the previous module if you need to reconnect to your EC2 instance via Session Manager.

 Time to Complete

15 minutes

 Services Used

Implementation

Step 1 : Installing the Apache web server

To run Drupal, you need to run a web server on your EC2 instance. A web server is a process that listens for HTTP requests, handles the request, and returns a response to users.

The open source Apache web server is the most popular web server used with Drupal.

To install Apache on your EC2 instance, run the following command in your terminal:

sudo dnf install -y httpd

You should see some terminal output of the necessary packages being installed.

You need to change a setting in your Apache configuration file. Open the file with nano with the following command:

sudo nano /etc/httpd/conf/httpd.conf

There is a block about a third of the way in the file that looks as follows:

In this block, change the “AllowOverride None” to read “AllowOverride All”.

You can save and exit from nano by entering CTRL + O followed by CTRL + X. 

 

In this block, change the “AllowOverride None” to read “AllowOverride All”.

You can save and exit from nano by entering CTRL + O followed by CTRL + X.

To start the Apache web server, run the following command in your terminal:

sudo service httpd start

You can see that your Apache web server is working and that your security groups are configured correctly by visiting the public DNS of your EC2 instance in your browser.

Go to the EC2 Instances page and find your instance. In the Description below, find the Public DNS (IPv4) of your instance.

Enter this value into your web browser, and you should see an Apache test page.

Now that your Apache web server is working, it’s time to download and configure Drupal.

Step 2 : Configure Drupal

In this step, you will install the Drupal software and set up the configuration.

Using the following instructions, you are going to install Drupal 10.2.6 and PHP version 8.2. If you would like to target different versions of Drupal, validate version compatibility with PHP using Drupal’s documentation here and alter the commands as appropriate.

First, install PHP and the various PHP dependencies by running the following commands.

sudo dnf install -y php8.2 php-dom php-gd php-simplexml php-xml php-opcache php-mbstring

If you chose PostgreSQL as your database engine, run the following command to install the PHP PostgreSQL library.

Note: Ignore this step if your database engine is MySQL

sudo dnf install -y php-pgsql

If you chose MySQL as your database engine, run the following command to install the PHP MySQL library.

sudo dnf install -y php-mysqlnd

Next, download and uncompress the Drupal software by running the following commands in your terminal:

sudo wget https://ftp.drupal.org/files/projects/drupal-10.2.6.tar.gz
sudo mv drupal-10.2.6.tar.gz tar.gz
sudo tar -xzf tar.gz
sudo mv drupal-* drupal

Change into the drupal directory and copy the files into the Apache root using the following commands.

cd drupal
sudo rsync -avz . /var/www/html
sudo chown -R apache:apache /var/www/html

Then, restart the Apache service

sudo service httpd restart

Your Drupal site is almost ready. In the next step, you will go through the Drupal site configuration wizard to create your site.

Step 3 : Set up Drupal site

Time to create your site. Once again, go to the EC2 Instances page and find your instance.

In the Description below, find the Public DNS (IPv4) of your instance.

Enter this value into your web browser.

Note: You may have issues running the Drupal set up process with certain configurations of Google Chrome. If you have problems, try using a different web browser to set up Drupal.

You should set the beginning of the Drupal setup wizard.

Choose the language you prefer and click Save and continue.

On the Choose profile screen, choose the Standard installation profile and click Save and continue button.

Next, choose profile as Standard: Install with commonly used features pre-configured and click the “Save and continue” button

It’s now time to set up your database. Select the database type that corresponds with the database engine you selected in Amazon RDS. If you chose MySQL, select the MySQL, MariaDB, Percona Server, or equivalent option. If you chose PostgreSQL, choose the PostgreSQL option.

Find your RDS database endpoint in the RDS console.

In the Drupal setup wizard, enter your configuration for Database name, Database user, and Database password. Then, click the Advanced options arrow to expand the options. In the Host field, enter the value for your RDS endpoint.

Click Save and continue. This will take a moment as Drupal creates your database tables and installs the necessary modules.

After installation is finished, enter the configuration for your site.

After entering your configuration, hit Save and continue to complete setup of your Drupal site.

You should see a success message and the beginning of your Drupal site.

Congratulations! You configured your Drupal website on Amazon EC2 using an Amazon RDS database. This setup will enable you to scale with low maintenance, allowing you to focus on what matters most to you.

In the next module, you will clean up the resources you created in this module and see some next steps.

Was this page helpful?

Clean Up and Next Steps