Build own CPanel

December 23, 2016 535 views
Getting Started Ubuntu 16.04

Ok, so this might sound like a stupid question and sorry if it has been asked before but is it possible to build my own CPanel?

DO provide API access for their services, which I could build a nice and Simple GUI for the controls I use.

Then I could just upload it to my droplet and that's it, right?

I don't see why I need to pay CPanel $20 per months.

Am I missing something? Very noobie at sysadmin here. I am just starting out with DO.

5 Answers

Yes you can make app utilizing API as alternative to cPanel, but only for managing Droplets and other DO resources, you can't control Droplet itself.
But that's not really needed. There are many great (maybe even better than cPanel) control panel solutions you can set up absolutely free.

Probably most popular solution here is ServerPilot.
Beside that there is VestaCP, Ajenti.
There is also Webmin that can help you control server.

Webmin is a web-based system administration tool for Unix-like systems. It provides an easy alternative to command line system administration and can be used to manage various aspects of a system, such as users and services, through the use of the provided Webmin modules. If you want to manage your own server but you are uncomfortable with the command line, Webmin is a good tool to help you get started. This tutorial covers the installation of Webmin with SSL using apt-get on Ubuntu 14.04.

The DigitalOcean API is to manage droplets, not software inside of the droplets.

First let me clarify a bit about how the API and how a system like cPanel/WHM work.

The DO API - This tool provides you access to the functions you can find in the DigitalOcean control panel, namely the ability to create and destroy droplets and volumes, create snapshots, gather basic information about your droplets, do reboots, power ups and power downs of your individual droplets and manage DNS records if your domain is pointed to the DO nameservers.

cPanel/WHM - This tool provides a web interface to manage a single server (it is possible to cluster multiple cPanel/WHM servers and do more but we'll stick to basic functionality). It allows you to manage several services on that server that are commonly used to deploy web applications including:

  • Apache or Nginx (Web Server)
  • PHP Programming Language
  • MySQL/MariaDB database server
  • BIND DNS Server
  • Mail server

Through cPanel you can create virtualhosts which are individual sites with their own folder, mail and DNS records on your server allowing you to provide end users access to this without getting access to the services of other users but all these sites are still run by the same web server process. cPanel will also include 3rd party tools like PHPMyAdmin which provides a web based interface to manage your databases.

To your main question: "Can I build my own cPanel". The answer is absolutely but it is almost certainly not worth the effort. Despite seeming like a fairly straightforward web application, a full stack web hosting management tool like cPanel is vastly complex both to create initially and possibly even more importantly, keep regularly updated and secure.

I have built 3 complete web hosting control panels in the past for previous companies I've worked for who wanted custom solutions for their hosting clients or for some other reason did not want to use cPanel/Plesk or one of the other commercial panels. In each case this required hundreds of hours of development, constant work on security updates and refinements going on for years afterwords and cost a LOT more than cPanel licenses would have.

There are open source alternatives out there like zPanel that are similar to cPanel and completely free. They cover most of the bases but often (not speaking specifically about zPanel as I've seen this with other panels over the years) the place where they fall down is in quickly responding to security vulnerabilities and making security updates available. Being community driven, without full time engineers means that these areas can sometimes not get the attention they require and could leave you vulnerable.

If you're interested in the inner workings of something like cPanel/WHM I would strongly recommend following some of the tutorials here to pick up the skills to manage all the services you want to run manually from the command line and configuration files first. That knowledge would be absolutely vital if you wanted to automate those processes and you will likely find that managing things that way makes a lot more sense unless you have a specific need for a shared hosting environment that end users will have access to. If you still want to create your own panel at that point you'll be armed with the knowledge of how to manage these services and can start automating it and creating interfaces. There is no one-size-fits-all API underneath a tool like cPanel, it's all command line functions and plaintext configuration files.

The TLDR here is: cPanel/WHM has a cost involved not just for the software but because they continue to support it. Your money covers the cost of managing security updates, providing end user support and keeping the panel up to date. There are free alternatives out there that provide the functionality though often without someone standing behind the tool providing timely security updates. The services that make up a Linux web stack were designed to be managed from the command line and security updates have less headaches when you use official packages so start there and decide if you want to build a panel.

You can use Zpanel. It's of course for free of charge.

@webydevyguy

To build upon what @ryanpq already said, building and managing a control panel isn't as cut and dry as it may seem. I've been working on one for quite some time myself (primarily targeting Ubuntu) for the past year and it's been love-hate. I've been working with Linux for about 15 years now and even though I've put that much time in to managing my own servers (by remotely and locally), managing other company-owned and personal servers, etc, it's a huge undertaking -- even more so for one person.

Unless you know the OS you're planning to use in and out, I'd use something that's already on the market. You have to also keep in mind what works on Debian may not work on Ubuntu (even though it's derived from Debian) and will not work on CentOS and so on.

Once you know your OS or OS's, you need to decide on how you're going to manage software. Are you going to compile from source or rely on package managers? If compiling from source, you're going to need to know how (which requires in-depth knowledge of compile options). If you plan on using package managers, know ahead of time that they are often behind the latest version and even when they're not, you're going with what one developer decided was best at the time they created that package.

Security is and will always be a subject all on its own. Needless to say, even solutions such as cPanel, Plesk, and various others are not natively secure by default. You still need to know how to manage a web server and you still need to know what to look for at the end of the day. You can't just install cPanel and call it a day -- it doesn't work like that and there's tons of horror stories from users who thought just that.

All this being said, it's not meant to discourage you. If you're new to managing your own servers, take your time and read tutorials & guides -- DigitalOcean has a ton! Find out what works for you and what doesn't. Write bash scripts that automate workloads (such as compiling NGINX from source, as an example). Once you have a good working set of bash scripts, and you have a good understanding, then you can look at optimizing those scripts, bringing them all together and creating a bash "framework" of sorts that will allow you to pass options and customize your deployment.

If you want to test something, deploy a CentOS Droplet and take a look at CentminMod.

https://github.com/centminmod/centminmod

It's open source and will give you an idea of what a rather large bash script looks like. It's written by an actual sysadmin that knows his stuff (speaking from experience).

  • Great additions. I've heard great things about Centminmond but haven't used it myself (aside from doing an installation or two). If you choose to go with an open source control panel I would strongly encourage selecting one that is designed to work with the distribution's native packages as you can then be assured of regular security updates.

    • @ryanpq

      CentminMod is actually pretty nice. Looking over the files, I think there's a great deal of work that could be done to reduce its size (i.e. there's a lot of duplicate code that would be better to include on startup rather than per call), but if you want relative ease of use, it works well.

      The author compiles from source when it comes to NGINX and using add-on repos for most other packages. Last I recall, the source compile of NGINX is because he's using OpenResty (still NGINX, but it's the latest Beta combined with a ton of modules + Lua).

      The only issue I've found with the OpenResty package is that when compiling from source, it often runs in to issues when you're compiling OpenSSL against it (during source compile). It works better when using the system OpenSSL, though that's often not the latest version. I ran in to that issue last night when testing the latest version.

Have another answer? Share your knowledge.