DEV Community

Cover image for Deploy cPanel & WHM on AWS EC2 Instance
Fady Nabil for AWS Community Builders

Posted on

Deploy cPanel & WHM on AWS EC2 Instance

  • cPanel & WHM is a web hosting control panel software that allows website owners, system administrators, and resellers to manage their websites and servers through a user-friendly interface. cPanel provides an easy-to-use graphical interface for managing various aspects of web hosting, such as creating email accounts, managing domains, uploading files, creating databases, installing applications, and monitoring server performance.

  • WHM (Web Host Manager) is a separate administrative interface that comes with cPanel. It allows system administrators and web hosting resellers to manage multiple cPanel accounts on a single server or across multiple servers. With WHM, you can create and manage hosting packages, set up new cPanel accounts, monitor server health and resource usage, and automate server backups and updates.

  • Together, cPanel & WHM provide a complete web hosting solution for both individual website owners and web hosting providers. They are widely used in the industry due to their ease of use, reliability, and comprehensive feature set.

Implementation

Creating an EC2 INSTANCE and Choosing CentOS 7 AMI

a. Open the AWS Management Console. When the screen loads, enter EC2 in the search bar, then select EC2 to open the service console.

Image description

b. Choose the Launch instance button to open the instance creation wizard.

Image description

c. On the first page, enter Web Hosting (cPanel & WHM) as your instance name.

Image description

d. Next, choose an Amazon Machine Image (AMI). The AMI you choose will determine the base software that is installed on your new EC2 instance. This includes the operating system (Amazon Linux, Red Hat Enterprise Linux, Ubuntu, Microsoft Server, etc.), and the applications that are installed on the machine.

Many AMIs are general-purpose AMIs for running many different applications, but some are purpose-built for specific use cases, such as the Deep Learning AMI or various AWS Marketplace AMIs.

CentOS 7 image is the Official CentOS 7 x86_64 HVM image that has been built with a minimal profile, suitable for use in HVM instance types only, so choose CentOS 7 (x86_64) - with Updates HVM after make search on AWS Marketplace AMIs in the AMI selection view.

so write CentOS 7 on search bar then click Enter

Image description

e. You will find the first image, choose it and press on Select

Image description

f. Read overview and all details about AMI then click Continue

Image description

g. You will return to the AMI Section and you will find that the image has been selected.

Image description

Choosing an instance type

Scroll down to select an EC2 instance type. An instance type is a particular configuration of CPU, memory (RAM), storage, and network capacity.

AWS has a huge selection of instance types that cover many different workloads. Some are geared toward memory-intensive workloads, such as databases and caches, while others are aimed at compute-heavy workloads, such as image processing or video encoding.

Amazon EC2 allows you to run 750 hours per month of a t2.micro instance under the AWS Free Tier.

a. Select the t2.micro instance.

Image description

Configuring an SSH key

You will see a details page on how to configure a key pair for your instance. You will use the key pair to SSH into your instance, which will give you the ability to run commands on your server.

a. Open the key pair (login) section and choose Create new key pair for your instance.

Image description

b. Give your key pair a name. Then choose .ppk in Private Key file format to can use with PuTTYThen. Then choose the Create key pair button, which will download the .ppk file to your machine. You will use this file later.

Image description

c. You will return to Key pair (login) Section and you will find that Key has been selected.

Image description

Configuring a security group and launching your instance

You need to configure a security group before launching your instance. Security groups are networking rules that describe the kind of network traffic that is allowed to your EC2 instance. You want to allow traffic to your instance:

  • SSH traffic from all IP addresses so you can use the SSH protocol to log in to your EC2 instance and configure WordPress.
  • HTTPS traffic from all IP addresses so that users can view your WordPress site Secured.
  • HTTP traffic from all IP addresses so that users can view your WordPress site.

a. To configure this, select Allow SSH traffic from Anywhere and select Allow HTTPS & HTTP traffic from the internet.
then Click on Edit

Image description

b. Click on Add Security group rule to add group rule.

Image description

c. First Security Group: In Port Range write 2087 and in Source type select Anywhere this for open WHM Dashboard Port.
Then Click on Add Security group rule to add another group rule.

Image description

d. Second Security Group: In Port Range write 2083 and in Source type select Anywhere this for open cPanel Dashboard Port.

Image description

Configuring storage on instance

a. Here we can increase the storage space for the Root volume and also can be added more volume storage.

Image description

Launch

It is now time to launch your EC2 instance.
a. Choose the Launch instance button to create your EC2 instance.

Image description

b. Wait for instance to launch.

Image description

c. You have successfully launched your EC2 instance and You can get Public IP.

Image description

SSH into your EC2 instance to know login information

You will use SSH to connect to your EC2 instance and run some commands.

a. Go to the EC2 instances page in the console. You should see the EC2 instance you created for the WordPress installation. Select it and you will see the Public IPv4 address and the Public IPv4 DNS in the instance description.
Click on Copy icon to copy public ip

Image description

b. Open PuTTY appliction and paste public ip in Host Name (or IP address).

Image description

c. Click on + the one next to SSH in Category list.

Image description

d. Then click on Auth.

Image description

e. In Private Key file for authentication, Click on Browse

Previously, you downloaded the .ppk file for the key pair of your instance. Locate that file now. It will likely be in a Downloads folder on your desktop.

open this .ppk file

Image description

f. Click on Open.

Image description

Configuration for CentOS to install cPanel & WHM

a. You should see the following in your terminal to indicate that you connected successfully.

then you will log in with centos (centos is deafult).

Image description

b. Enter this command to change password

sudo passwd
Enter fullscreen mode Exit fullscreen mode

Image description

c. Enter this command to be root user

su root
Enter fullscreen mode Exit fullscreen mode

Image description

d. Enter Password to be root user (Password you added a while ago in a sudo passwd step).

Image description

e. Enter this command to update image

yum update
Enter fullscreen mode Exit fullscreen mode

Image description

f. Enter y to accept download Package.

Image description

g. Enter this command to install perl package

yum install perl
Enter fullscreen mode Exit fullscreen mode

Image description

h. Enter y to accept download Package.

Image description

i. Enter this command to install wget package

yum install wget
Enter fullscreen mode Exit fullscreen mode

Image description

j. Enter y to accept download Package.

Image description

k. Enter this command to install nano package

yum install nano
Enter fullscreen mode Exit fullscreen mode

Image description

l. Enter y to accept download Package.

Image description

m. set the hostname with your domain name. Replace yourdomainname.com with your domain name.

hostnamectl set-hostname cpanel.yourdomainname.com
Enter fullscreen mode Exit fullscreen mode

Image description

n. Download the latest installation script from cPanel's website by running the following command

curl -o latest -L https://securedownloads.cpanel.net/latest
Enter fullscreen mode Exit fullscreen mode

Image description

o. Once you have downloaded the installation script, run the following command to start the installation process

sh latest
Enter fullscreen mode Exit fullscreen mode

Image description

p. The installation process will now begin. Follow the on-screen instructions to complete the installation.

Image description

q. Make reboot for server, run the following command

reboot
Enter fullscreen mode Exit fullscreen mode

Image description

WHM & cPanel setup

a. back to EC2 Instance Dashboard and select EC2 then Copy Public Ip.

Image description

b. Once the installation is complete, you can access the WHM interface by visiting https://your-server-public-ip:2087 in your web browser then click on Advanced

Image description

c. Click on Proceed to ... (unsafe)

Image description

d. WHM Login Page Open.
On the WHM login page, enter the "root" username and the password you set during the instance launch process then click on Login.

Image description

e. Click on Agree to All.

Image description

f. Click on Log in to log in to cpanel store.

Image description

g. Click on Create an Account.

Image description

h. Enter email address then click on the approval box (I agree ...) then click on Create Account.

Image description

i. Click on Allow Access.

Image description

j. After recieve verification code on email copy it and enter it in WHM then click on Verify My Email.

Image description

k. Click on Server Setup.

Image description

l. Here you can add Nameservers and setup domain or click on Skip and edit in it later.

Image description

m. Now you will be taken to the WHM home page.

Image description

n. In Search Tools write Create and click on Enter to make Search then click on Create a New Account to use it to open Cpanel Login.

Image description

o. Enter all data about account you need to create then click on Create and this data will use to Log in Cpanel dashboard.

Image description
Image description

p. Now you can access the cPanel interface by visiting https://your-server-public-ip:2083 and enter username and password to login.

Image description

That's it! You now have cPanel & WHM installed on your AWS EC2 instance. From here, you can manage your server, create hosting accounts, and more.

Oldest comments (1)

Collapse
 
milanmaximo profile image
Milan Leon

All these with Linode is exactly with 4 clicks.
What's the point of all of these steps just to install cPanel?! To much wasting of time.
Anyhow, it is great tutorial.