Deploy cPanel & WHM on AWS EC2 Instance
Tags: aws, cpanel, ec2, hosting
Published: 2023-03-27 23:20:34

- 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](https://console.aws.amazon.com/console/home). When the screen loads, enter **EC2** in the search bar, then select **EC2** to open the service console.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lqf8rhbktyo1hfc515gr.png)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pjkmu55zhxiskszrrmgr.png)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ffjuvrtpjimy5f4issl6.png)

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](https://aws.amazon.com/marketplace/pp/prodview-qkzypm3vjr45g) after make search on AWS Marketplace AMIs in the AMI selection view.

so write **CentOS 7** on search bar then click **Enter**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/blgle49r9rhkxgnt8zdu.png)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r6a72lx3vuwvszbq9lu6.png)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i4nwxsr4ob2kdytmd02r.png)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mp13sq3ahpagenzromsv.png)


### 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](https://aws.amazon.com/ec2/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](https://aws.amazon.com/free/).

a. Select the **t2.micro** instance.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c3uwtr3dthc83no9uu13.png)

### 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](https://en.wikipedia.org/wiki/Secure_Shell) 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yl87xerefx9euh6s0v72.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7qbx0ad367q6ohdjubqh.png)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rrzai2cfcp6tcwsx2980.png)

### 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4nx1nzat9nrytzkj2o0b.png)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ji4zet78zq34g45lqv5k.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8eoez3fw56ncn6qpz59l.png)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uxqqcfs6mbxjxvb0qv80.png)

### 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m937po5cdkiod6w2gr7p.png)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3w9622z9ikwfmxfi0axx.png)

b. Wait for instance to launch.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8refp2kx6pf0xmdcy1z4.png)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bm160ldtac08oe58dzu5.png)

### 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](https://console.aws.amazon.com/ec2/v2/home#Instances) 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3qpj4t0l12sj3evj2jtv.png)

b. Open [PuTTY](https://www.putty.org/) appliction and paste public ip in _Host Name (or IP address)_.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nq8a1ukr5y2zl7xs7beu.png)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sfwbjaqu8ijzcdsmkzun.png)

d. Then click on **Auth**.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p33rw0sx9b2m7jqlglnp.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iok0xmrj3ffvxzro32pm.png)

f. Click on **Open**.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7ghzfipueqwu5kpn5rvj.png)

### 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gt0o0aou8zvk7irboaj8.png)

b. Enter this command to change password

```
sudo passwd
```

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xenm19l207al1rec3cbn.png)

c. Enter this command to be root user

```
su root
```

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2jj9xqcvxvs8wg1lpid2.png)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e1qxdx4g0ozm6qtocjmb.png)

e. Enter this command to update image

```
yum update
```

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ojiw1cbzhp4j1x9e8fzn.png)

f. Enter **y** to accept download Package.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eajr9ougtzt47ldcl1om.png)

g. Enter this command to install perl package

```
yum install perl
```

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ycslnocjvgvgwxufc9uk.png)

h. Enter **y** to accept download Package.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1fpe413oha08ji001mdq.png)

i. Enter this command to install wget package

```
yum install wget
```

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rb42aq2ihk9wfgjx9sa8.png)

j. Enter **y** to accept download Package.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5w0rqwvixa0i268w00s1.png)

k. Enter this command to install nano package

```
yum install nano
```

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h05xsb81f9009rzyxwox.png)

l. Enter **y** to accept download Package.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/prmv2rnvg1cuuty5772u.png)

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

```
hostnamectl set-hostname cpanel.yourdomainname.com
```

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/47e20cll8wq9iihv5jeu.png)

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

```
curl -o latest -L https://securedownloads.cpanel.net/latest
```

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jdg1mkfwm740m0wuzr51.png)

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

```
sh latest
```

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0gmwt6f2d3k2sebd2b69.png)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uy7hs7vlrp2gqm0w7s32.png)

q. Make reboot for server, run the following command

```
reboot
```

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i79qw1kixf871tno6fzb.png)

### WHM & cPanel setup

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qhnwmu1uf2kswo2y3djq.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jy8yiz4qegtmryln8kea.png)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cfhn4qszqq8hwu04m2pe.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s6s6xhw29ox3ggq0gee5.png)

e. Click on **Agree to All**.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vdhe7exz9v7erkwetsq5.png)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nbxaeum8tzfss34nijrx.png)

g. Click on **Create an Account**.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j3k5knosge0gqaiwdn7i.png)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nqhd7xrq36299zgl6y11.png)

i. Click on **Allow Access**.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4pdvi4hdiki0ppfm9i7t.png)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6184myzwzfumrn6lyge3.png)

k. Click on **Server Setup**.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kwox00t5k2jyulq12998.png)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uz5u9ohk45e0rv9f24oj.png)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n2sebubkw0dum4i7ybj9.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/krzz5qo4d31l98qjiabe.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4dni7zmdpbyly1qyxj6e.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gnpb4r8po0hmosr7j1mx.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z6cj799o0ss4z4bsr0zy.png) 


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.