Archive for June, 2018

How to install Drupal 8 on Amazon EC2 Linux AMI

June 10, 2018

Drupal 8 is the leading open source enterprise Content Management System (CMS).

The following post outlines the steps necessary to install Drupal 8 on an Amazon Web Services EC2 instance.

Open console.aws.amazon.com using your favourite web browser

Launch an EC2 instance. I chose the following AMI

Amazon Linux AMI 2018.03.0 (PV) - ami-f40c388d

It is probably best to create a Security Group for Drupal so you can assign more ports later if necessary.

I experienced issues installing on a t1.micro instance type. The installation kept stalling and would not finish. I had to install on a m1.small and then change the instance type after installation.

SSH to your instance.

Updates may have been released since the AMI was created. To install the latest patches run the following command.

yum update

Install Apache 2.4

yum install httpd24

Now configure Apache so it starts when the instance boots.

/sbin/chkconfig httpd on

Apache is not started as part of the installation process. To start it enter the following:

service httpd start

Install MySQL 5.7

yum install mysql57-server

Now configure MySQL so its starts when the instance boots.

/sbin/chkconfig mysqld on

MySQL is not started as part of the installation process. To start it enter the following:

service mysqld start

Now that MySQL is installed and running it needs to be secured.

mysql_secure_installation

Follow the prompts.

Install PHP

yum install php71

Install PHP extensions

The PHP build comes with most of the necessary extensions, i.e. XML, JSON, Curl, etc.

To install the remaining necessary extensions

yum install php71-mysqlnd
yum install php71-gd
yum install php71-mbstring

Download Drupal 8.5.4

curl https://ftp.drupal.org/files/projects/drupal-8.5.4.tar.gz > drupal-8.5.4.tar.gz

Uncompress and untar

tar -zxvf drupal-8.5.4.tar

Install Drupal files

sudo rsync -avz . /var/www/html

In order for the installation to work some permissions need to be changed.

cd /var/www/html
chmod a+w sites/default
chown -R apache:apache /var/www/html

Configure web server

vi /etc/httpd/conf.d/drupal.conf

Insert the following into the file.

<VirtualHost *:80>
DocumentRoot /var/www/html

<Directory "/var/www/html">
AllowOverride All
</Directory>

</VirtualHost>

Restart Apache to ensure setting changes picked up

service httpd restart

Install Drupal, setup database and configure

Open your favourite web browser and go to the site

Ignore opcode caching and continue

Database name = drupal
user = root
pass = password-you-set

Configure Drupal

Follow the prompts.

The installation is now complete! Open your favourite web browser and check the installation works.