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 solid 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 simple.
Okay! Now that we are done with some of the 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.
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 which, you will simply “Continue to Configuration” which again is located at the top-right corner.
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 select 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.
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 supports.
Disclaimer # 3 Your EC2 instance type determines the rate at which AWS bills you. Make certain that you select an instance type that includes appropriate resources for the type 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 on 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 select the desired VPC or subnet.
Under 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.
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.
Finally, select the “Launch” button on the bottom-left corner and you will be taken to a notification page with the following confirmation information.
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 IP’s can be 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:
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. You can connect with us via cPanel Forums, Discord or Slack, or join our Reddit community on /r/cPanel!