Deploying Drupal on Amazon Web Services (AWS)

How to Deploy Drupal 8 on AWS

At the time of writing, Drupal 8 hasn’t been officially released yet, however, there is a Beta version available. I thought I would try and get the jump on everyone and see if I could install it on an AWS Instance. Also, the description of the Official Drupal 8 Website sounds interesting:

Drupal 8 will set a new standard for ease of use, while offering countless new ways to tailor and deploy your content to the Web. Easily customize data structures, listings, and pages, and take advantage of new capabilities for displaying data on mobile devices, building APIs, and adapting to multilingual needs.

If you are keen to try the steps in this article for yourself, you’ll need

  1. …an EC2 Ubuntu version running on AWS or at least know how to get one up and running*
  2. …to be able to connect to this instance via AWS CLI

*This may work with other Linux/Unix installations besides Ubuntu, but I can only guarantee it on a recent Ubuntu installation
With that in mind let’s get started.

Step 1.  Install a LAMP stack

Assuming that you are now logged into your EC2 server, you need to install the LAMP stack.  I suggest you become the super user, run apt-get and install the LAMP package. (apt-get is a package/software manager.)
Become the super user.

sudo -s

Update apt-get so that it has the most recent information

apt-get update

Install the LAMP server software. Be sure to include the “^” (which identifies lamp-server as a meta-package).

apt-get install lamp-server^

Answer ‘yes’ when prompted about disk space

3 upgraded, 27 newly installed, 0 to remove and 58 not upgraded.
Need to get 43.4 MB of archives.
After this operation, 115 MB of additional disk space will be used.
Do you want to continue [Y/n]? y

****Enter a MySQL password when prompted**** (this password will be used again, so record it).
Create a new database for your site

mysql -u root -p -e "CREATE DATABASE drupaldb CHARACTER SET utf8 COLLATE utf8_general_ci;"

Log in and set the access database rights:

mysql -u root -p

****Enter your MySQL password from above**** (you did record it, right?)
At the MySQL prompt, set the permissions using the following command: (where “password” is your MySQL password)

GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES ON drupal.* TO 'root'@'localhost' IDENTIFIED BY 'password';

If successful, MySQL will reply with:

 Query OK, 0 rows affected

Now exit the MySQL prompt by typing:

exit

The server will answer by saying

Bye

So, if that all worked, you should now have a LAMP stack set up on your Ubuntu AWS instance.

Step 2.  Install Drupal 8

In this step, I will suggest you just use your normal login – which should probably be ubuntu – rather than the superuser. If you are still in superuser mode from the above step, just type “exit”.

Move to Apache’s web server directory.

cd /var/www/html

Get the current Drupal 8 version.

sudo wget https://www.drupal.org/files/projects/drupal-8.0.0-beta10.tar.gz

The following command will unpack Drupal 8 and put everything where it needs to go, including several additional hidden Drupal 8 files.

sudo tar --strip-components=1 -xzvf drupal-8.0.0-beta10.tar.gz

Delete the archive.

sudo rm drupal-8.0.0-beta10.tar.gz

Copy the following files as shown.

sudo cp sites/default/default.settings.php sites/default/settings.php
sudo cp sites/default/default.services.yml sites/default/services.yml

Set the correct permissions.

sudo chmod 666 sites/default/settings.php
sudo chmod 666 sites/default/services.yml
sudo chmod a+w sites/default

Restart Apache.

sudo service apache2 restart

If all that went well, then you should be able to point your browser to your Public DNS and see the Drupal 8 setup up page:

Drupal 8 Set up page
Drupal 8 on AWS

Follow the installation steps, answering questions when prompted. If you’re unsure about any answers, see the Drupal installation guide starting at Step 4.

Step 3. Secure your site

After the installation is complete, you will want to restore the original (more secure) permissions on the following files.

sudo chmod 644 services.yml
sudo chmod 444 settings.php
sudo chmod 555 default/

Step 4.  Configure clean URLs

After my installation, I found that my pages were given strange URLs that included an “index.php”. I fixed the problem by running:

sudo a2enmod rewrite
sudo service apache2 restart

…by adding the following in my /etc/apache2/apache2.conf file

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=https://d1o2okarmduwny.cloudfront.net/favicon.ico
RewriteRule ^ index.php [L]

…and by restarting Apache one more time:

sudo service apache2 restart

Avatar

Written by

Michael Sheehy

I have been UNIX/Linux System Administrator for the past 15 years and am slowly moving those skills into the AWS Cloud arena. I am passionate about AWS and Cloud Technologies and the exciting future that it promises to bring.

Related Posts

Avatar
Michael Sheehy
— August 19, 2019

What Exactly Is a Cloud Architect and How Do You Become One?

One of the buzzwords surrounding the cloud that I'm sure you've heard is "Cloud Architect." In this article, I will outline my understanding of what a cloud architect does and I'll analyze the skills and certifications necessary to become one. I will also list some of the types of jobs ...

Read more
  • AWS
  • Cloud Computing
Avatar
Nitheesh Poojary
— August 16, 2019

Boto: Using Python to Automate AWS Services

Boto allows you to write scripts to automate things like starting AWS EC2 instances Boto is a Python package that provides programmatic connectivity to Amazon Web Services (AWS). AWS offers a range of services for dynamically scaling servers including the core compute service, Elastic...

Read more
  • Automated AWS Services
  • AWS
  • Boto
  • Python
Avatar
Andrew Larkin
— August 13, 2019

Content Roadmap: AZ-500, ITIL 4, MS-100, Google Cloud Associate Engineer, and More

Last month, Cloud Academy joined forces with QA, the UK’s largest B2B skills provider, and it put us in an excellent position to solve a massive skills gap problem. As a result of this collaboration, you will see our training library grow with additions from QA’s massive catalog of 500+...

Read more
  • AWS
  • Azure
  • content roadmap
  • Google Cloud Platform
Avatar
Adam Hawkins
— August 9, 2019

DevSecOps: How to Secure DevOps Environments

Security has been a friction point when discussing DevOps. This stems from the assumption that DevOps teams move too fast to handle security concerns. This makes sense if Information Security (InfoSec) is separate from the DevOps value stream, or if development velocity exceeds the band...

Read more
  • AWS
  • cloud security
  • DevOps
  • DevSecOps
  • Security
Avatar
Stefano Giacone
— August 8, 2019

Test Your Cloud Knowledge on AWS, Azure, or Google Cloud Platform

Cloud skills are in demand | In today's digital era, employers are constantly seeking skilled professionals with working knowledge of AWS, Azure, and Google Cloud Platform. According to the 2019 Trends in Cloud Transformation report by 451 Research: Business and IT transformations re...

Read more
  • AWS
  • Cloud skills
  • Google Cloud
  • Microsoft Azure
Avatar
Andrew Larkin
— August 7, 2019

Disadvantages of Cloud Computing

If you want to deliver digital services of any kind, you’ll need to estimate all types of resources, not the least of which are CPU, memory, storage, and network connectivity. Which resources you choose for your delivery —  cloud-based or local — is up to you. But you’ll definitely want...

Read more
  • AWS
  • Azure
  • Cloud Computing
  • Google Cloud Platform
Joe Nemer
Joe Nemer
— August 6, 2019

Google Cloud vs AWS: A Comparison (or can they be compared?)

The "Google Cloud vs AWS" argument used to be a common discussion among our members, but is this still really a thing? You may already know that there are three major players in the public cloud platforms arena: Amazon Web Services (AWS), Microsoft Azure, and Google Cloud Platform (GCP)...

Read more
  • AWS
  • Google Cloud Platform
  • Kubernetes
Avatar
Stuart Scott
— July 29, 2019

Deployment Orchestration with AWS Elastic Beanstalk

If you're responsible for the development and deployment of web applications within your AWS environment for your organization, then it's likely you've heard of AWS Elastic Beanstalk. If you are new to this service, or simply need to know a bit more about the service and the benefits th...

Read more
  • AWS
  • elastic beanstalk
Avatar
Stuart Scott
— July 26, 2019

How to Use & Install the AWS CLI

What is the AWS CLI? | The AWS Command Line Interface (CLI) is for managing your AWS services from a terminal session on your own client, allowing you to control and configure multiple AWS services and implement a level of automation. If you’ve been using AWS for some time and feel...

Read more
  • AWS
  • AWS CLI
  • Command line interface
Alisha Reyes
Alisha Reyes
— July 22, 2019

Cloud Academy’s Blog Digest: July 2019

July has been a very exciting month for us at Cloud Academy. On July 10, we officially joined forces with QA, the UK’s largest B2B skills provider (read the announcement). Over the coming weeks, you will see additions from QA’s massive catalog of 500+ certification courses and 1500+ ins...

Read more
  • AWS
  • Azure
  • Cloud Academy
  • Cybersecurity
  • DevOps
  • Kubernetes
Avatar
Stuart Scott
— July 18, 2019

AWS Fundamentals: Understanding Compute, Storage, Database, Networking & Security

If you are just starting out on your journey toward mastering AWS cloud computing, then your first stop should be to understand the AWS fundamentals. This will enable you to get a solid foundation to then expand your knowledge across the entire AWS service catalog.   It can be both d...

Read more
  • AWS
  • Compute
  • Database
  • fundamentals
  • networking
  • Security
  • Storage
Avatar
Adam Hawkins
— July 17, 2019

How to Become a DevOps Engineer

The DevOps Handbook introduces DevOps as a framework for improving the process for converting a business hypothesis into a technology-enabled service that delivers value to the customer. This process is called the value stream. Accelerate finds that applying DevOps principles of flow, f...

Read more
  • AWS
  • AWS Certifications
  • DevOps
  • DevOps Foundation Certification
  • Engineer
  • Kubernetes