- Amazon account
- A terminal – (PuTTY is recommended for Windows users)
Sign into your Amazon account and go to the AWS console page. Click on “EC2″
Next we want to create a new “Security Group” for your future EC2 instance.
Then click on the “Create Security Group” button.
In the popup, enter your new group name and description. I’ve chosen the name and description to be “Drupal 7 Web Group”. Then click “Yes, Create”.
Once the group has been created, we need to allow for HTTP/HTTPS/SSL traffic to be allowed by creating inbound firewall exceptions for this security group. Select the newly created security group, and at the bottom of the page, switch the tab over to “Inbound”.
From the drop down list select “SSH”.
Click “Add Rule”.
Repeat these steps for HTTP, HTTPS, and any other protocols you might be using, however SSH and HTTP are required. MYSQL is not required unless you will have other external servers accessing the MySQL server hosted on your new EC2 instance.
Now you must apply the changes, for the changes to be saved.
After the changes have been applied, we need to create a new “Key Pair”, so select “Key Pairs” from the sidebar.
Choose the button at the top, “Create Key Pair”.
Enter a new name for the key pair, I chose, “Drupal7WebGroup”.
Then choose, “Create”.
The key file (.pem) should automatically be downloaded by your browser. You are going to want to keep this file in a safe place, we will be using it later.
Creating An EC2 Instance
On the sidebar, choose “Instances”
Then choose the button to “Launch Instance”.
Stick the with default, “Classic Wizard” and choose “Continue”.
Here you have a choice on which Amazon Machine Image (AMI) you wish to use. If you are familiar enough with Linux they choose your favourite flavour, but for the purposes of this tutorial, I am going to choose, “Ubuntu Server 12.10 64-bit”.
On the next page, we get a choice of hardware. If you just signed up for Amazon Web Services (AWS), you are eligible for a free year of micro hosting on the lowest tier. It’s a great place to start and has enough resources to run a small Drupal 7 without any problems. I recommend the lowest tier if you’re just starting out, you can always upgrade it later with no problems.
You can leave the rest of the settings default, or change them as you see it, then choose “Continue”.
The next page allows for some more configuration, but the default settings will work just fine, choose “Continue”.
The next page is an overview of the storage device configuration, nothing to do here but click “Continue”.
Now you want to name your instance, for this tutorial, we will name it “Drupal 7 Web Server”, then press “Continue”.
Now we get to apply the key pair we created earlier to this instance. Select the key pair you created earlier, then press “Continue”.
Next we choose our existing security group that we created earlier, then press “Continue”.
Our instance is complete, and here is the overview page. Choose “Launch” to launch the instance.
Assigning an Elastic IP to Your EC2 Instance
On the sidebar, choose “Elastic IPs”.
Then choose the button at the top to “Allocate New Address”.
Choose “EC2″ and click “Yes, Allocate”.
Select the new Elastic IP address from the list, and choose the button at the top, “Associate Address”. Then choose the new web server in the select box, and click, “Yes, Allocate”.
Converting Your Private Key (.pem) File to PuTTY’s Private Key (.ppk) File
Now that we have a IP associated with the instance we can connect over SSH, however if we are using PuTTY we need to convert that .pem key file to a .ppk file that works with PuTTY, so let’s open the program PuTTYgen.exe
Choose “Load” and find your .pem file that was saved early when creating key pairs.
Change the file type at the bottom to “All Files (*.*)” and then find the .pem file you saved earlier. Choose “Open”.
Now save this file to a safe place by clicking the button, “Save private key”. Ignore the warning about the passphrase.
Connecting Over SSH to Your New EC2 Instance with PuTTY
Open PuTTY, and in the Host Name (or IP Address), enter in “ubuntu@ip_address” where the IP address is the elastic IP that we assigned to the instance earlier.
Then in the left panel, open “SSH” and select “Auth”. In the “Private key file for authentication” browse for your key and open it.
Next, go back to the left panel and click “Session” at the top, type a name in the blank field and save your session for later use.
Now click, “Open”. If everything was done right you should get a pop up that asks you to add the rsa2 key fingerprint. Choose “Yes”.
You are now connected to your server.
Setting up the LAMP Stack (Apache2, PHP5, MySQL5)
Run these commands to get everything set up properly and efficiently
Update the releases
sudo apt-get update
Preform and upgrade on server libraries, Type “Y” at the prompt.
sudo apt-get upgrade
sudo apt-get install lamp-server^ phpmyadmin
Choose “Y” at the prompt to install the packages.
Enter a strong password for the MySQL root user. Twice.
On the following screen press SPACE, TAB, ENTER.
For the PHPMYADMIN setup, press , then enter a strong password twice, could be the same as the root password you used before. Twice.
Now we need to enable the Apache modules needed for Drupal.
sudo a2enmod rewrite expires headers
Then restart your apache2 server.
sudo service apache2 restart
Your web server is now configured, install Drupal in /var/www, or else you can create virtual hosts to handle multiple site installations.
Pointing your DNS at your new web server
You need to go to your domain manager and change the A Record to your new server’s Elastic IP address that we set up earlier.