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 a database on 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 deploying Drupal in HA mode, you can mail us at [email protected]
Install and Setup Drupal on Amazon EC2
To set up 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 the 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 a Database and User
Log in to the 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 parameters 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
until 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.
6 comments
This site is quite educating. i got more information than i was looking for.
Thank you.
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
Thanks, Jignesh. I have added it.
Hi Sir, Very Useful Article. Thanks for Sharing
Very clear and easy to follow.
Thank you for this guide. However, how do you configure the email system? Drupal’s mail() php function does not work with AWS EC2 after installing. How do you make email work?