How To: Set Up cPanel & WHM on Amazon Web Services

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)

3.4.  Configure your instance details

    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

sudo su

6.3.  Install Perl

yum install perl

6.4.  Install WGET

yum install wget

6.5.  Go to home

cd /home

6.6.  Get latest cPanel

wget -N http://httpupdate.cpanel.net/latest

6.7.  Execute installation files

sh latest

6.8.  Wait while it installs (can take a while)

6.9.  Set root password. passwd root follow the instructions.

6.10.  In a browser, go to https://Your.IP.Address:/2087

6.11.  Use root as the name and your root password as the password, click login

You should now be in your fresh install of WHM ready for you to configure to your liking. I recommend configuring a security policy to regulate the ports we opened at the beginning. Also, don’t forget to set your hostnames.


Update:

In case you missed it in the comments below, Antoine from Tribulant has done a wonderful job expanding upon this to include information on how to set up Amazon EC2 nameservers with WHM

80 Comments

Wael Hossam gravatar icon Wael Hossam

I followed all instructions successfully until I got to the CPanel installation using sh latest
Then it started and reached a point saying:
/usr/sbin/spacewalk-channel –list
Unable to locate SystemId file. Is this system registered?
2014-05-05 19:21:08 923 (ERROR):
2014-05-05 19:21:08 925 (ERROR): $> /usr/sbin/subscription-manager repos
2014-05-05 19:21:09 926 (ERROR):
This system has no repositories available through subscriptions.
Removing /root/installer.lock
>

What do you think I am missing here?

Reply
Olmeca gravatar icon Olmeca

You can use CentOS 6, I got same error on some different systems, finally I set it up on CentOS 6 and then it is working fine.

Reply
vikas gravatar icon vikas

hi,

i am in big trouble. please help me . I need your reply.

how much you paid to “amazon web service ” company for integrating with cpanel.

becuase cpanel uses 20gb of hard disk. I heard we have to pay for “amazon web service” for “disk space”

Did you paid money, if so how much you paid for amazon web service[ec2] for integrating with cpanel.

Thanks in advance.

Reply
Wael Hossam gravatar icon Wael Hossam

just to try I register on Redhat website and was able to launch:
subscription-manager register
typed my user name and pass:
Username: wael_hossam
Password:
then I got this message:
wael_hossam cannot register to any organizations.

Here I have no idea what else I can do.

Reply
Rob Scott gravatar icon Rob Scott

Hi-
I am not sure. I did not register on the RedHat website, I think AWS should do that for you when you start an instance. I’m just assuming though.
I think you should be able to do everything through the AWS web portal.

Reply
Antonie gravatar icon Antonie

Great tutorial, thank you very much!
It was extremely useful and I used this as reference to setup my own Amazon EC2 instance with WHM.

I did it a bit differently though, attaching two elastic IPs to the same network device.
Then I registered two private nameservers for the two IPs and set those up in a DNS zone in WHM.
Now I can point all my domains to those two nameservers and it works great.

Amazon EC2 is amazing, so easy to use!

Reply
Rob Scott gravatar icon Rob Scott

That’s a great idea! I will have to try that out on an install and see if I like it better.
Thanks for the feedback!

Reply
Rex Varghese gravatar icon Rex Varghese

Hi,

Could you please let me know how you setup the aws to use WHM. I got struck in the nameserver area. It would be really grateful if you can explain the following thing “attaching two elastic IPs to the same network device.
Then I registered two private nameservers for the two IPs and set those up in a DNS zone in WHM”

Thanks,
Rex

Reply
Rob Scott gravatar icon Rob Scott

I would refer to their documentation because general support for AWS is outside of my scope of knowledge.
Cheers!

Reply
Antonie gravatar icon Antonie

Sure, I’ll tell you how I did it.

First, you’ll go to EC2 in AWS and create 2 private IPs on the 1 network device for the instance. Then go to elastic IPs and create 2 elastic IPs and associate each one with a private IP on the instance.

Then go to your registrar like GoDaddy or Dynadot and register two new, private nameservers eg ns1.domain.com and ns2.domain.com each with one of those public IPs you created under elastic IPs.

Then do your WHM installation. During the installation it will ask you to specify IPs. Or alternatively, afterwards you can go to IP Functions > Add New IP. Since it will be in NAT mode by default, you’ll fill in the private IP you specified on the instance, not the public, elastic IP. WHM will automatically route the private IP to the public one and it will also automatically map the nameservers for those IPs at the registrar. Do this for you second IP as well, add it in WHM. Remember to add the private IP on the instance in WHM, else it will not work.

After a few minutes or an hour or so, go to DNS Functions > NS Record Report and you’ll see that the nameservers have automatically resolved to the two IP addresses you specified. WHM does this automatically.

Now you can go and point many domains to these two nameservers and they will automatically propagate to the new server.

Great thing about EC2 is that it comes with built in reverse DNS as well so no need to do anything there specifically.

Reply
Alan gravatar icon Alan

I was curious why you created two name-servers when Route53 will create 4 DNS nameserver instances for each of your registered subdomains. Was perhaps Route53 not ready when you did this?

Thanks

Reply
Santa gravatar icon Santa

Alan, that would work too, but if you use Rob’s way ( or Antonine’s ) then you will be able to hide the public dns name under a “vanity” nameserver ( ex: ns1.yourdomain.tld instead of the delegation set )

Daniel gravatar icon Daniel

Hi Rob,

Not a techie but am having an AWS pro migrate my sites.
He informs me if Cpanel is set up on AWS,
cannot utilise AWS scalability (?)

Any feedback on this would be much appreciated.
Thanks, Daniel

Reply
Rob Scott gravatar icon Rob Scott

I think that was my experience as well. You could map things in a way that minimized the strain of resources on your cpanel/whm installs by leveraging the elastic components of their hosting environment for storage etc.

Reply
k.c gravatar icon k.c

Hi
Since hostgator decided to sell itself to badly managed hosting giant I am thinking of moving all my sites down to a AWS. I have some questions. Please let me know if you have any experiance on them

1. What do you mean by cannot use scalability? Can we
a. Save the AMI and recreate the production set-up (possibly with larger instance )
b. Adding additional storage
c. Using ELB and have 2-3 server instances behind it ?
D. using amazon RDS instead Database on the Linux server

I assume that WHM would use host header to identify differnet website. only recently AWS started supporting host headers on ELB. have you tested that?

Cheers

K.C

Reply
Rob Scott gravatar icon Rob Scott

I would refer to their documentation since I do not and cannot provide sales or general support for AWS since a lot of it is outside of my scope of knowledge relating to their products. I do not understand your question about host headers either.
Cheers!

Reply
Richard Jacob gravatar icon Richard Jacob

This post and the one referenced by Antonie Potgieter are very helpful to someone like me; running a VPS at GoDaddy and having a tough time paying through the nose every time I need another 20 or 30 GB of space and getting “virtually” no support (sorry for that.) I mean, if I’m not going to get any (or much) help and I’m going to have to figure it all out myself anyway, I may as well go to Amazon and have the added benefit of truly flexible space and bandwidth. The only roadblock to making the plunge (for me) was just not having a clue how to navigate the conundrum that is the AWS interface.
Thanks for posting this…I can’t thank you enough.

Reply
Rob Scott gravatar icon Rob Scott

I am so glad that it helped you, it makes the time it took to write and screenshot everything worth it.
Thanks for the comment.

James gravatar icon James

Hi!

Anyone can setup multiple IP address for this to work ?
I mean binding 2 or more IP on the cpanel/whm on ec2 ?

Reply
Sterlin gravatar icon Sterlin

Thanks for your tutorial, it was really simple to follow,
At the end however, in enter https://ip-address:/2087 and I get the default error

“The server can not find the requested page:
Please forward this error screen to–ip-adddress”

did I do something wrong?

Reply
Rob Scott gravatar icon Rob Scott

Did you replace the “ip-address” in the url with the ip address of your hosing environment?

Reply
Rob Scott gravatar icon Rob Scott

This installs WHM / cPanel on Amazon AWS.
They can be used to administer a hosting environment.

Reply
prem anand gravatar icon prem anand

I got this error while compile cpanel in amazon ec2
[20141103.004535] Retrieving and staging /cpanelsync/11.44.1.19/cpanel/scripts/validate_sshkey_passphrase.bz2
[20141103.004535] E Could not uncompress /usr/local/cpanel/scripts/validate_sshkey_passphrase-cpanelsync.bz2:
[20141103.004535] E bzip2: Can’t create output file /usr/local/cpanel/scripts/validate_sshkey_passphrase-cpanelsync: No space left on device.
[20141103.004535] E Failed to uncompress /usr/local/cpanel/scripts/validate_sshkey_passphrase-cpanelsync.bz2

Can’t exec “/usr/local/cpanel/scripts/cpanel_initial_install”: No such file or directory at /home/cPanelInstall/selfgz1229/install line 146.
2014-11-03 00:45:37 148 (FATAL): Failure to exec /usr/local/cpanel/scripts/cpanel_initial_install
Removing /root/installer.lock

Reply
Rob Scott gravatar icon Rob Scott

I am not sure but one of your errors looks like there is no space on the device…

[20141103.004535] E bzip2: Can’t create output file /usr/local/cpanel/scripts/validate_sshkey_passphrase-cpanelsync: No space left on device.

Which I would assume is the problem.

Reply
Felipe Garan gravatar icon Felipe Garan

Why i have this error?

———————-
2014-11-13 20:54:00 429 ( INFO): cPanel install started at: Thu Nov 13 20:54:00 2014!
2014-11-13 20:54:00 430 ( INFO): This install will take 20-50 minutes depending on your hardware.
2014-11-13 20:54:00 431 ( INFO): Now is the time to go get another cup of coffee/jolt.
2014-11-13 20:54:00 432 ( INFO): The install will log to /var/log/cpanel-install.log.
2014-11-13 20:54:00 433 ( INFO):
2014-11-13 20:54:00 434 ( INFO): Beginning Installation v3
2014-11-13 20:54:00 338 ( INFO): CentOS 6 (Linux) detected!
2014-11-13 20:54:00 362 ( INFO): Validating that ‘ip-10-0-0-128’ is a FQDN
2014-11-13 20:54:00 368 (ERROR):
2014-11-13 20:54:00 369 (ERROR): ********************* ERROR *********************
2014-11-13 20:54:00 370 (ERROR):
2014-11-13 20:54:00 371 (ERROR): Your hostname (ip-10-0-0-128) is not set properly. Please
2014-11-13 20:54:00 372 (ERROR): change your hostname to a fully qualified domain name,
2014-11-13 20:54:00 373 (ERROR): and re-run this installer.
2014-11-13 20:54:00 374 (ERROR):
2014-11-13 20:54:00 375 (ERROR): ********************* ERROR *********************
2014-11-13 20:54:00 376 (FATAL): exiting…

———————-

What can i do to solve that?

Thanks

Reply
Rob Scott gravatar icon Rob Scott

The info in the error says :
Your hostname (ip-10-0-0-128) is not set properly. Please change your hostname to a fully qualified domain name, and re-run this installer.

Reply
Himanshu gravatar icon Himanshu

Your host name is not setup properly . please change your host name to fully qualified domain name error……
How to solve it?

Reply
Pete Wilcock gravatar icon Pete Wilcock

[…] on setting up a CPanel environment, so we were mostly sustained by a couple of good articles by Rob Scott and Antonie Potgieter. CPanel themselves wrote an article on how to set up the environment but […]

Reply
Ed Mendonca gravatar icon Ed Mendonca

Hi,
Have I become a registered user on cPanel to install WHM/cPanel in my instance no AWS?

Does AWS offer any type of web service that come with WHM/cPanel installed??

Thanks.

Reply
Rob Scott gravatar icon Rob Scott

Hi-
I am not sure I understand.
I think the answer is that you have to install / register cPanel/WHM yourself and that Amazon does not have a one click solution to install it for you. I could be wrong, so you might want to check with Amazon.

Reply
Ed Mendonca gravatar icon Ed Mendonca

On more thing: MySQL, FTP Server, MailServer are installed with WHM/cPanel?

I’m a VPS user for a lot of years but all of that VPS that I used came with WHM/cPanel, MySQL Server, FTP Server, MailServer, WebMail installed, so I´m afraid to make all of this configuration by myself.

Thanks.

Reply
Rob Scott gravatar icon Rob Scott

I think most of that should come bundled with whatever flavor of Linux you are using. You can then install WHM/cPanel and manage those services through WHM.

Reply
Rob Scott gravatar icon Rob Scott

Hi Ed –
I used CentOS.
I think that I could not get WHM to install on flavors other than CentOS which is why I did not use Cloud Linux. Now that I think about it, I am not sure Cloud Linux was around when I did it. I will definitely check it out now that I know it exists. It looks like it might be a good solution with cPanel rolled into it which would make the installation simpler.
Thanks,

Reply
Heri Setiawan gravatar icon Heri Setiawan

I’m really new to this thing, and got stuck at step 5 , where I should ‘Click on Go To Record Sets and add an a entry for your public IP address’. Which IP addresses should I set it on? Is it the elastic IP that has been set earlier?

Reply
Augustus gravatar icon Augustus

I ran into a problem at the install cpanel step – I got an error regarding no hostname to resolve I just used the following command – hostname your FQDN ex: hostname mydomain.net

Reply
Augustus gravatar icon Augustus

I followed the steps in the post to install/config everything.. I am unable to open up the cpanel through browser with https://my.domain:/2087.
I entered it with my public ip address. and with using http (port 80) I get:

Not Found
The requested URL /2087 was not found on this server
Apache/2.4.12 (Unix) OpenSSL/1.0.1e-fips mod_bwlimited/1.4 Server at SERVER IP Port 80

I have opened the ports: 80, 443, and 22. I’m not sure what I did wrong.

If I go to http://mydomain.net I get the cpanel Sorry page from the cgi_sys dir

Reply
Augustus gravatar icon Augustus

I got it….Had to use https;\\my.domain.net:2087 instead of https;\\my.domain.net:\2087

Reply
vamsi gravatar icon vamsi

hi,

Can you please guide me in adding 2 network interfaces to cpanel which is hosted in AWS.
I was able to add the 2nd network interface in AWS and mapped it to cpanel, but when we add a second private ip in the new network interface it cannot be mapped to the elactic ip’s

Thanks

Reply
Rob Scott gravatar icon Rob Scott

Hi Vamsi
I wrote this post over a year ago and do not use the AWS products anymore so I am not familiar with any changes that may have happened on the AWS side of things.
Sorry I can’t be of more assistance.

Reply
Rob Scott gravatar icon Rob Scott

Hi Matthew-
It really depends on your application.
For me the decision was based on cost & speed.
I feel like greater speed gains come from the location of the server in relation to the user base. Most of what I host is local business so the redundancy etc that AWS offers was not as important to me in this application as the speed gains with a server closer to the users.
It is also relatively expensive especially compared to more traditional hosting environments.

Reply
Michael O gravatar icon Michael O

followed the steps in the post to install/config everything.. I am unable to open up the cpanel through browser with https://my.domain.com
I entered it with my public ip address. and with using http (port 80) I get:

Not Found
The requested URL was not found on this server
Apache/2.4.12 (Unix) OpenSSL/1.0.1e-fips mod_bwlimited/1.4 Server at SERVER IP Port 80

I have opened the ports: 80, 443, and 22. I’m not sure what I did wrong.

If I go to http://mydomain.net I get the cpanel Sorry page from the cgi_sys dir

Reply
Abinash R gravatar icon Abinash R

Cpanel installed on VPC EC2 is same as on any VPS. How can we control multiple cpanel installed on multiple EC2 and achieve cloud architecture for further expansion. Cpanel confirms they require static IP and doesn’t support Cpanel.

Reply
tejas nimje gravatar icon tejas nimje

After Execute installation files command

sh latest

i am getting the following error

When you use Red Hat Enterprise Linux®, you must register
2015-12-02 09:02:45 1028 (ERROR): with the Red Hat Network before you install cPanel & WHM.
2015-12-02 09:02:45 1029 (ERROR): Run the following command to register your server: /usr/sbin/rhn_register

i tried : /usr/sbin/rhn_register but its not working

Can anyone resolve this?

Reply
Wayne Sharer gravatar icon Wayne Sharer

This is great information. One small detail. You cannot do this cPanel/WHM install if you already have MySQL or Maria DB installed on your server. Amazon gives great instructions for configuring your linux instance. However, since Amazaon doesn’t really care about cPanel or WHM they just continue with MySQL.

So when you configure your Linux instance, you must install cPanel/WHM before you add MySQL to your server EC2 instance or this procedure will not work.

If someone knows what to do when you already have MySQL installed, I would love to know.

Reply
Aalina gravatar icon Aalina

Will probably give a try
I am currently running EC2 instance without cPanel & WHM
just want to hot multiple sites in future

Reply
Graham gravatar icon Graham

Hi, thanks for this very useful article. I have a question, now that Amazon has released Lightsail could I just create an Amazon Linux OS instance and install cPanel and WHM on that?

Thanks in advance.

Reply
Rob Scott gravatar icon Rob Scott

Hi Graham –
I don’t use AWS anymore so I was a little out of the loop on what Lightsail was, so thanks for turning me on to it. I would assume since you can have a lamp stack you should probably be able to do it, but I didn’t fire up a Lightsail VPS to find out. Let me know if you do.
Rob

Reply
Rob Scott gravatar icon Rob Scott

I do not understand the difference. I think elasticip.com:2087 is just a generic placeholder for what the elastic IP would be. If you used a domain name you could probably do that, but it would change some of the steps.

Reply
DNS gravatar icon DNS

Hi, I setup a an AWS EC2 instance on Cent OS (WHM & cPanel). However, even though I put a index.php pages in the public_html folder (to print just Hello World”), I am still getting a 404 Not Found error. Not just that, I also tried creating a folder ‘test’ within public_html and placed a similar index.php file there but it gives the same error. What could be the reason? Thank you.

Reply
Deepak gravatar icon Deepak

Hey Rob, this is an great tutorial I really appreciate your efforts. I just setup everything but I got an error after installation.

When I entered https://myipaddress:/2087 in my browser it shows me 404 error can please help me there, I’m a newbie!
Thanks again!

Reply

Leave a Reply

Your email address will not be published. Required fields are marked *