This post was written in 2014, and its information might be outdated. Please refer to Amazon’s AWS documentation for the most up to date information, as I am not able to provide support or assistance for configuring AWS.
For a few years now, I have been hearing about the benefits of Amazon’s Elastic Compute Cloud, but had resisted making the switch because of their lack of integration with the web host management tools that I prefer to use, cPanel & WHM, .
I finally got talked into firing up an instance in Amazon AWS, and in the process have really begun to appreciate the technology integrated into Amazon Web Services. The ability to scale and deploy on demand are enough that I don’t anticipate going back to dedicated hardware anytime soon.
The capabilities of Amazon’s AWS are pretty incredible, but I missed the familiarity and ease of use of cPanel & WHM to manage my hosting environment. I began looking into how to install cPanel & WHM on AWS, but found most of the information outdated or in multiple places, making it a struggle to walk through. I decided to put together a set of steps that would walk through how to set up a VPC, Security Groups, Your EC2 instance, S3 Storage, Route 53 DNS and cPanel/WHM using Amazon Web Services.
How To: Set Up cPanel & WHM on Amazon Web Services
First things first, you need to login to your Amazon AWS Management Console at https://console.aws.amazon.com
1. Setup VPC
1.1. Click the VPC icon under Compute & Networking
1.2. Click the Start VPC Wizard button
1.3. Select “VPC with a Single Public Subnet Only” and click continue
1.4. Review the Subnet information and edit the VPC IP CIDR Block if you want to add additional IP Addresses. (The allowed block size is between /28 and /16 meaning you can have up to 65,536 IP addresses)
1.5. Click the Create VPC button to create your VPC
2. Setup Security Groups
2.1. Click the VPC icon under Compute & Networking
2.2. Click Security Group on the menu
2.3. Name your Security Group and select the VPC ID from the VPC dropdown and click Yes, Create
2.4. Add rules to your group (select the group you want to edit and options will appear underneath available groups)
I configure mine to allow all traffic in and I manage ports through cPanel/WHM.
If you want to do it that way, select Inbound and create a rule for all traffic; make source 0.0.0.0/0 and click add rule.
3. Setup Amazon EC2 Instance
3.1. Select EC2 and click the blue Launch Instance button
3.2. Install your preferred AMI. (I could only get cPanel/WHM to install on CentOS)
3.3. Choose the size of your instance. (I start small since AWS scales so easily)
a. Set desired Network & Subnet
b. Add your desired IAM Role to add AWS access keys
c. Set Shutdown Behavior “Stop” (otherwise it will be terminated)
d. Enable Termination Protection (Makes termination a two step process preventing accidental termination)
e. Under Network Interfaces add a Primary IP Address based off of the subnet range you chose
f. Set your desired Kernal, Ram Disk and User Data (or use default)
3.5. Add your desired storage
Amazon offers a few different kinds of storage, for this instance, our options are root and EBS. Root storage is in the EC2 instance so when the instance gets terminated the data gets terminated. EBS is independent of the EC2 instance so data will not be terminated with the instance.
3.6. Tag your instance and create a name for it.
3.7. Configure Security Group
Select the radio button for “Select an existing security group” and select the security group we created earlier
3.8. Review & Launch
Make sure everything looks the way you want it to and click Launch.
3.9. Select a Key Pair
You can add an existing key or select Create New Key Pair, add a name for your key pair and download it. Use puttygen to crete a private key.
4. Setup Elastic IP
4.1. Select EC2 and click the Elastic IP’s menu item
4.2. Click the blue Allocate New Address button
4.3. Use the Instance dropdown to set your instance to the one you will be using
4.4. The private IP address should populate with the Primary IP address you added earlier
4.5. Click the Reassociation check box (to keep the IP associated with the instance even if instance is rebooted.)
4.6. Click the associate button to finalize your changes
5. Setup Route 53 DNS
I decided to try Route 53 to configure my hostnames for this project. I went and purchased a domain and decided I would use that for my hostnames.
5.1. Click the create hosted zone button
5.2. Add the domain name you want to use, give it a comment if you want
5.3. Go back to your domain registrar and set your own custom name servers as the four under delegation set
5.4. Click on Go To Record Sets and add an a entry for your public IP address
At this point your DNS should be configured to have the elastic IP address be used for your EC2 instance we created. You can use tools like network-tools.com to determine if your DNS is acting right or not. We will come back to this later when we discuss configuring nameservers.
6. Setup cPanel/WHM
Now that you have your Amazon AWS configured, you can have some fun with installing and configuring cPanel/WHM.
6.1. SSH into your instance (Your username may be ec2-user)
6.2. Take root
6.3. Install Perl
yum install perl
6.4. Install WGET
yum install wget
6.5. Go to home
6.6. Get latest cPanel
wget -N http://httpupdate.cpanel.net/latest
6.7. Execute installation files