Getting Started with AWS

Deploy Drupal with Amazon RDS

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 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 SSH into your EC2 instance. Please review the steps in the previous module if you need to reconnect to your EC2 instance via SSH.

 Time to Complete

15 minutes

 Services Used

Implementation

  • 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 yum 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:

    # Further relax access to the default document root:
    <Directory "/var/www/html">
        #
        # Possible values for the Options directive are "None", "All",
        # or any combination of:
        #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
        #
        # Note that "MultiViews" must be named *explicitly* --- "Options All"
        # doesn't give it to you.
        #
        # The Options directive is both complicated and important.  Please see
        # http://httpd.apache.org/docs/2.4/mod/core.html#options
        # for more information.
        #
        Options Indexes FollowSymLinks
    
        #
        # AllowOverride controls what directives may be placed in .htaccess files.
        # It can be "All", "None", or any combination of the keywords:
        #   Options FileInfo AuthConfig Limit
        #
        AllowOverride None
    
        #
        # Controls who can get stuff from this server.
        #
        Require all granted
    </Directory>

    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.

     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.

    You should see an Apache test page

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

  • Configure Drupal

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

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

    sudo amazon-linux-extras install -y php7.2
    sudo yum install -y 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.

    sudo yum install -y php-pgsql
    

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

    wget https://www.drupal.org/download-latest/tar.gz
    tar -xzf tar.gz
    mv drupal-* drupal

    If you run “ls” to view the contents of your directory, you will see a tar file and a directory called drupal with the uncompressed contents.

    $ ls
    drupal  tar.gz

    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.

  • 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.

    Go to the EC2 Instances page and find 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.

    Drupal setup wizard

    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.

    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.

    Drupal setup wizard

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

    Installing Drupal screen

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

    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.

    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 module helpful?

Thank you
Please let us know what you liked.
Close
Sorry to disappoint you
Is something out-of-date, confusing or inaccurate? Please help us improve this tutorial by providing feedback.
Close

Clean Up and Next Steps