Building cPanel Web Hosting on Amazon AWS

Let’s say you need to find hosting for multiple web applications with cPanel backend access so clients cannot access each other’s backends. What can you do to create a secure hosting environment without paying for several different hosting accounts?

Why not host it yourself?!

Disclaimer: If you have one or two lightweight websites, this probably isn’t the most cost-effective route to go. However, if you are currently paying to host several websites and have some technical background, hosting a site yourself may be a great route to consider. So stick around, and we’ll show you how to build a hosting environment on Amazon AWS using the cPanel and WHM Amazon Machine Image (AMI)!

Before we dive into the actual process, be sure to read the Amazon® AWS ™ User Guide.

Amazon’s AWS platform exists behind a NAT infrastructure. This infrastructure provides a robust hosting architecture that uses the following Amazon AWS features:

These features, combined with cPanel/WHM/DNSOnly, make deployment and provisioning of new servers unbelievably rapid and straightforward.

Getting Started

Ok! Since we’ve finished with some housekeeping items, let’s dive into the meat of the process. First things first, you’ll need to sign-up for Amazon Web Services. The sign-up process is very straightforward, but you may have a wait a few minutes for the account creation to complete, allowing you to access all the services in the AWS Marketplace.

After successfully creating an account, let’s start by navigating to the cPanel & WHM AMI in the AWS Marketplace.

Disclaimer #2: cPanel’s support team only support the official cPanel & WHM AMI. Check to see that cPanel is listed as the creator.

cPanel & Whm for Linux Screenshot from the Amazon Marketplace

Once on the cPanel & WHM for Linux page, navigate to the top-right corner and click “Continue to Subscribe.” You will be taken to a “Subscribe to this software” page, which you review the Terms and Conditions. After this, you will simply “Continue to Configuration,” which again can be found at the top-right corner.

Configuration Options

Upon arrival to the Configuration page, you will be presented with the Fulfillment Option, Software Version, and Region. For the Software Version, we recommend the most recent version of cPanel, and for Region, double-check that AWS automatically selected the correct region. If this is not correct, simply click Region and choose a new region.

Note: Remember the region you selected for when we get to the “create a key pair” step. You must configure the key pair and instance to use the same region. If they do not use the same region, you cannot use the key pair with the instance. You also cannot edit the instance region after you launch the instance.

Next, select “Continue to Launch” in the top-right corner.

Screenshot of the install panel for cPanel & WHM for Linux on the Amazon Marketplace with Continue to Launch button

The next interface you will arrive at is the “Launch this software” page where most of the customization happens. Under the “Choose Action” section, you may continue with “Launch from Website,” which is the default selection.

Under “EC2 Instance Type”, select the instance type that you wish to use. The list of instance types includes all of the types that the cPanel & WHM AMI support.

Options for customizing your instance when setting up cPanel on AWS

Disclaimer # 3 Your EC2 instance type determines the rate at which AWS bills you. Make sure that you select an instance type that includes appropriate resources for the kind of system that you wish to run. If you host a large number of websites or multimedia content, you must choose an instance type that exceeds our minimum system requirements.

Continuing, we will configure the Virtual Private Cloud (VPC) settings. Under VPC. Settings, verify the Virtual Private Cloud (VPC) and subnet that the system selected. We deferred to the default option. If you would like to change one of these settings, click VPC. Settings and choose the desired VPC or subnet.

Options for further customizing your instance when setting up cPanel on AWS

Under the Security group, check the port and security settings. We recommend that you select “Create New Based on Seller Settings”. We’ve pre-configured this to meet our system requirements and improve security for your system. So simply name your security group and provide a brief description and be on your way!

Note: Only advanced users should select default.

Screenshot of security group settings when installing cPanel on AWS

Next, you will need to select or create a key pair. Under Key Pair, verify whether the system selected is the desired key pair. To create a key pair, select “Create a key pair in EC2” and then select “Create Key Pair” to have a new one generated for you. Reminder: Ensure you are in the region you selected earlier to launch your software! Next, refresh the section (not the page) using the circular arrows next to the drop-down menu and select the new key pair you just created.

Screenshot of Key Pair Settings for installing cPanel on AWS

Launching Your Instance and Logging in for the First Time

Finally, select the “Launch” button on the bottom-left corner, and you will be taken to a notification page with the following confirmation information.

Screenshot of Launch confirmation for installing cPanel on AWS

Please keep in mind new instances may require several minutes to initialize. Until the initialization process finishes, the Status Checks column of the EC2 Management Console will display Initializing and an hourglass icon.

When you launch an instance, it is assigned a hostname that is a form of the private, internal IPv4 address. The hostname is set from the AWS Console, and if you don’t set it correctly when the instance is first built, you cannot change it within cPanel/WHM Well you can, but it is a multistep process, so you are better off setting your hostname while the instance is initializing.

In case you forget, you can find how to change your hostname here.

Additionally, you will want to associate your instance with an elastic IP so you can be sure your IP address doesn’t change in the future when stopping or restarting your instance. The documentation on AWS’s elastic IPs is found here.

You can view your instances on the EC2 Console, which is hyperlinked on the notification page or view all your instances in “Your Software.” It will take you to a page that looks like this:

Screenshot of all instances in the AWS while installing cPanel

Before you login to WHM for the first time, you will need to set the root password for the server since the AWS AMI does not automatically assign you one. To do this, log in via SSH as the centos user using the key you downloaded earlier from setting up key pairs. Establish an SSH connection to the server by using the following syntax: ssh root@IPaddress. Once you’re in, run “sudo su -” to become root, and then “passwd” to set the password. You’ll be asked to type the password twice.

Ok now grab your IP address so we can log in to WHM or cPanel for the first time. There are two ways to login, but the easiest way to get started is to use your server’s IP address and port 2087 for WHM and port 2083 for cPanel. That login would look like this: https://127.0.0.1:2087. Replace that 127.0.0.1 in the address with the IP of your server. Please note, you will need to accept the SSL warning the first time you log in. For more tips on logging in for the first time, please reference our knowledge base here: How to Log in to Your Server.

And there you have it! An easy, flexible, and cost-effective way of hosting your websites. We’d love to hear what you think about this blog post. 

Updated Aug, 19th 2020 | cPanel is excited to be added as a blueprint on Amazon Lightsail. Getting started with cPanel on Lightsail has never been easier!  Find out to How to get started with cPanel on Amazon Lightsail!

You can connect with us through any of our social channels for discussion, including Discord, our cPanel forums, and our official cPanel subreddit. You can also sign up for the cPanel Essentials Briefing List to receive emails about important updates.

Building cPanel Web Hosting on Amazon AWS

Building a cPanel web hosting environment on Amazon AWS requires a combination of AWS services, especially the Elastic Compute Cloud (EC2), along with the cPanel & WHM software. Here’s a step-by-step guide to achieve this:

Prerequisites:

  • An AWS account.
  • Basic understanding of AWS services, especially EC2.
  • Familiarity with cPanel & WHM.

Steps to Set Up cPanel on AWS:

  1. Setting up EC2 Instance:
    • Go to the AWS Management Console.
    • Select EC2 and click on Launch Instance.
    • Choose an Amazon Machine Image (AMI). cPanel recommends using the CentOS 7 or CloudLinux 7 x86_64 AMI.
    • Choose an instance type. Depending on your expected workload, t2.medium or larger might be appropriate.
    • Configure instance details. Use default settings unless you have specific requirements.
    • Add storage. Ensure you allocate sufficient storage based on your hosting requirements.
    • Add tags. This is optional but helps in identifying the instance.
    • Configure Security Group. Open ports 20, 21, 22, 53, 80, 110, 143, 443, 465, 587, 993, 995, 2077, 2078, 2082, 2083, 2086, 2087, 2095, 2096. This is to ensure that all services of cPanel & WHM work correctly.
    • Review and launch the instance.
  2. Assign Elastic IP:
    • In the EC2 dashboard, go to “Elastic IPs”.
    • Allocate a new IP and associate it with your running instance. This ensures that the IP remains fixed, even if the instance is restarted.
  3. Installing cPanel:
    • Connect to your EC2 instance using SSH.
    • Download the cPanel installation script: curl -o latest -L https://securedownloads.cpanel.net/latest
    • Run the installation script: sh latest
    • The installation process might take some time. Once done, cPanel & WHM will be installed.
  4. Accessing WHM:
    • In a browser, go to https://YOUR_ELASTIC_IP:2087.
    • Log in with the username root and the password for the EC2 instance.
    • Complete the post-installation wizard, setting up nameservers, services, etc.
  5. Configure Hostname and DNS:
    • It’s recommended to set a fully qualified domain name (FQDN) as your hostname.
    • Update DNS settings with your domain registrar to point to your AWS environment.
    • Ensure your nameservers and A records are set correctly.
  6. Set Up Additional Services:
    • Install and configure firewall settings.
    • Set up email services, databases, etc.
    • Monitor resources and optimize as necessary.
  7. Backup Configuration:
    • AWS offers several backup solutions, including EBS snapshots.
    • You can also use cPanel’s built-in backup solutions and store backups on Amazon S3.
  8. Scaling:
    • As your hosting needs grow, you can resize your EC2 instance or set up load balancing solutions.
    • AWS’s RDS service can be used for scalable database solutions.
  9. Monitoring and Management:
    • Utilize AWS CloudWatch to monitor the performance of your EC2 instance.
    • cPanel & WHM also provide various monitoring tools.
  10. Security:
  • Regularly update cPanel & WHM.
  • Implement security best practices for both AWS and cPanel.
  • Consider using AWS WAF for additional web application security.

Remember, while AWS provides robust infrastructure, managing a cPanel web hosting environment requires regular monitoring, updates, and optimization to ensure performance and security.

Previous Post
2018 #cPConf Wrap-Up
Next Post
WHM Feature Showcase update

Get Online Today!

  

Your perfect domain name is waiting!

Search our huge portfolio for more domain name extensions and pricing below
domain name extensions

Classic Domain Names

.COM | .AU | .CO | .NET | .BIZ | .ME | .EU | .ASIA | .TV | .MOBI | .NAME | .INFO | .ORG | .US | .NL| .FM | .HK | .ES | .CO.NZ | .DE | .CO.UK | .RU | .IM | .PM | .TW | .FR | .CN | .CA | .CH | .VN | .PL | .IL | .JP | .KR |