Migrating an on-premise Cpanel to AWS

cpanel aws brown and white dog

The Challenge

If you don’t know Cpanel, think of it as an all-in-one open-source box. Cpanel is a powerful hosting server with built-in services such as Apache, PHP, Mysql, and Named for DNS. It allows you to create customised hosting packages and host customers over them. Usually, it’s well suited to small customers. The biggest challenge starts when you put more and more load within the same box.

What about a scenario where you don’t have a single hosting package although you have built your solution years ago over Cpanel APIs? These APIs are used to provision email accounts, FTP users, DNS records, and so on.

You would end up with an infrastructure design like this:

All-in Cpanel

Even though you have a big server to handle all the workloads, what happens if the server goes down? And if you have that server hosted in a third-party data center? You would have to raise a ticket and wait for their answer. Meaning a big downtime ahead.

The Solution

Since decoupling services and applications into micro-services is a complex and long process, the fastest solution was to lift and shift the server to a similar Cpanel server on an EC2 instance.

That choice gave time to the developer teamwork on the overwhelming applications while allowing some standard applications to be pushed to the Cloud.

Previously, all the PHP Laravel APIs running on that box were modernised to docker images and deployed on ECS.

Check it out our open-source terraform ECS cluster module:

aHR0cHMlM0ElMkYlMkZnaXRodWIuY29tJTJGRE5YTGFicyUyRnRlcnJhZm9ybS1hd3MtZWNz

And our module to deploy ECS applications such as PHP Laravel:

aHR0cHMlM0ElMkYlMkZnaXRodWIuY29tJTJGRE5YTGFicyUyRnRlcnJhZm9ybS1hd3MtZWNzLWFwcA==

If you want to find out more about application modernisation for PHP, Node, Ruby, etc, check out our website:

aHR0cHMlM0ElMkYlMkZkbnguc29sdXRpb25zJTJGYXBwbGljYXRpb24tbW9kZXJuaXNhdGlvbiUyRg==

DNS to Route 53:

Dumping all Route 53 records from a Cpanel server is a pain in the neck. Why’s that? Because Cpanel usually creates a lot of ‘useless’ records if you’re creating a single domain or subdomain.

We managed to have all the DNS records and values and we’ve created all of them on Route 53.

There is no simple way to dump the DNS records on Cpanel. Be aware of that.

It is always DNS

Mysql to RDS:

The databases on Cpanel are created with a strange prefix to avoid duplication. We’ve got a dump of all databases, and using the python script below, we ran a 40 or so parallel syncs to restore all databases:

aHR0cHMlM0ElMkYlMkZnaXRodWIuY29tJTJGRE5YTGFicyUyRnRvb2xzLWJveCUyRmJsb2IlMkZtYXN0ZXIlMkZzY3JpcHRzJTJGcGFyYWxsZWwtc2NyaXB0JTJGcGFyYWxsZWxfZGJfcmVzdG9yZS5weQ==

Now we have a server running on AWS and at least some ways to handle the forthcoming problems.

Right now, the solution is not yet finalised, so stay tuned for our next posts where we will update you with the next stages of this migration.

To Be Continued…

[promo_banner image=”2230″ style=”shadow” text_alignment=”center” content_width=”100″ woodmart_css_id=”5ffff22d5f001″ link=”url:https%3A%2F%2Fgithub.com%2FDNXLabs%2F|||” title=”Click here to access our open-source projects on GitHub!” hide_btn_tablet=”no” hide_btn_mobile=”no” increase_spaces=”no” img_size=”medium”][/promo_banner]

[html_block id=”1164″]

[html_block id=”1336″]

Plan Your Next Move with Confidence
Ready to align your technology with your business growth strategy? Talk to DNX about modernising your platform for scalability, resilience, and faster time-to-market.
Related Insights

Insights to help you navigate an evolving digital landscape.