How To Install and Setup Drupal On Amazon EC2 Instance

drupal installtion on amazon ec2

In this guide, I will explain how to install and setup Drupal on amazon ec2 ubuntu 14.04 server. This is a standalone installation with Drupal and database in a single server. For high traffic websites, it is advised to have a High Availability architecture with autoscaling and dedicated database instances. If you need help in deploying Drupal in HA mode, you can mail us at [email protected]

Install and Setup Drupal on Amazon EC2

To setup Drupal on an EC2 instance, you need the following on the server.

1. LAMP stack.
2. Few PHP modules related to Drupal
3. A dedicated database for Drupal.

Follow the guides given below to set up a working Drupal installation.

Spin Up an EC2 instance

Spinning up an EC2 instance is really easy. Follow this tutorial if you haven’t done that before. How to Spin Up an Ec2 Instance

Add Relevant Security Groups

Add the relevant port in the ec2 instance security group. In our case, we would require port 80 and 22. If you are setting up SSL in future, you might need to add 443 as well.

Connect to the new instance

You can follow this tutorial to connect to the instance using putty. How to connect EC2 instance using putty

Install LAMP Stack

1. Update the server.

sudo apt-get -y update

2. Install the lamp stack.

sudo apt-get -y install lamp-server^

Give a password when it prompts for it.

3. Verify the Apache installation by visiting the public IP of your instance. You should get a default apache page on your browser.

4. Verify MySQL server status

sudo service mysql status

Install PHPMyAdmin

sudo apt-get install phpmyadmin

Open /etc/apache2/apache2.conf and add the following at the end of the line.

Include /etc/phpmyadmin/apache.conf

Restart apache2

sudo service apache2 restart

Now you will be able to access PHPMyAdmin over the browser by appending phpmyadmin to the ip as shown below.

http://52.34.132.67/phpmyadmin/

Create Database and User

Login to database.

mysql -u root -p

Create database

CREATE DATABASE drupaldb;

Create a drupal user.

CREATE USER drupaluser IDENTIFIED BY 'password';

Grant all privileges to the drupaluser.

GRANT ALL PRIVILEGES ON drupaldb.* TO drupaluser;
FLUSH PRIVILEGES;

exit database.

exit;

Install php modules

sudo apt-get update
sudo apt-get install php5-gd php5-curl libssh2-php

Open /etc/php5/apache2/php.ini, search and set the following parmeters to off.

expose_php = Off

allow_url_fopen = Off

Enable apache rewrite functionality

sudo a2enmod rewrite

Open /etc/apache2/sites-enabled/000-default.conf and change parameters as shown below.

Note: Replace example.com with your domain name and [email protected] with your email address.

<VirtualHost *:80>
    ServerName  example.com
    ServerAdmin [email protected]
    DocumentRoot /var/www/html

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

Restart apache

sudo service apache2 restart

Download Drupal Files

Go to https://www.drupal.org/download

Download the latest version

https://ftp.drupal.org/files/projects/drupal-8.0.5.tar.gz

untar the files

sudo tar -zxvf drupal-8.0.5.tar.gz

cd into the extracted drupal directory and copy all the files to /var/www/html using the following command.

cd drupal*
sudo rsync -avz . /var/www/html

Set permissions of user and group

sudo chown -R www-data:www-data /var/www/html

Install and Setup Drupal

Now, access the install page in the browser using the public IP of your instance and continue as normal Drupal installation. Give the database username and password that you have created during the database setup process.

That’s it. Once you complete the web-based installation, you will have a working Drupal Website.

0 Shares:
5 comments
  1. Please add a point in here that for http the aws security group inbound rules must be updated to accept incoming traffic at port 80

Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like