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 Module: 15 Minutes


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

    Module4-step1a

    (Click to enlarge)

    Module4-step1a

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

    Module4-step1b

    (Click to enlarge)

    Module4-step1b

    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.

    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.

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

    Module4-step3a

    (Click to enlarge)

    Module4-step3a

    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.

    Module4-step3b

    (Click to enlarge)

    Module4-step3b

    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.

    Module4-step3c

    (Click to enlarge)

    Module4-step3c

    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.

    Module4-step3d

    (Click to enlarge)

    Module4-step3d

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

    Module4-step3e

    (Click to enlarge)

    Module4-step3e

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

    Module4-step3f

    (Click to enlarge)

    Module4-step3f

    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.

    Module4-step3g

    (Click to enlarge)

    Module4-step3f

    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.