How to Install cPanel on a Linux Server. A Complete Guide for System Administrators

Installing cPanel on a Linux server isn’t just about running a single script and walking away. It’s about laying a solid foundation for managing websites, email, DNS, and databases with precision. This guide is written for system administrators who want a clean, controlled, and reliable deployment of cPanel & WHM on a Linux-based VPS or dedicated server.


1. System Requirements

Let’s get clear: cPanel is resource-hungry. It’s built for production workloads, not experimental tinker-boxes. Here’s what you’ll need:

Operating System

  • Supported: CentOS 7, AlmaLinux 8/9, Rocky Linux 8/9, CloudLinux
  • Unsupported: Ubuntu, Debian, Fedora – cPanel doesn’t support them.

Hardware (Minimum)

  • 2 CPU cores
  • 2 GB RAM (4 GB recommended)
  • 40 GB disk space (SSD preferred)
  • Static IP address (IPv4 is required)
  • Root SSH access

No control panels should be pre-installed (Webmin, Plesk, etc.). cPanel expects a clean slate.


2. Prepare Your Server

Before touching any installation script, prep the server. Clean, consistent environments are easier to debug and manage.

Step 1: Update the System

Use yum or dnf, depending on your OS version.

# CentOS 7 / AlmaLinux 8
yum update -y

# AlmaLinux 9 / Rocky 9
dnf update -y

Reboot if the kernel or system packages were upgraded:

reboot

Step 2: Set a Fully Qualified Domain Name (FQDN)

This is critical. cPanel uses it as the server’s primary hostname.

hostnamectl set-hostname server.example.com

Edit your /etc/hosts file:

nano /etc/hosts

Add a line like this:

123.123.123.123 server.example.com server

Replace 123.123.123.123 with your server’s IP.


3. Disable Network Manager (if needed)

cPanel prefers network service, not NetworkManager. Some newer OS versions use NetworkManager by default.

Check with:

systemctl status NetworkManager

If active:

systemctl stop NetworkManager
systemctl disable NetworkManager
systemctl enable network
systemctl start network

4. Disable SELinux

cPanel does not play nicely with SELinux.

Check status:

sestatus

If enabled, edit the config:

nano /etc/selinux/config

Set:

SELINUX=disabled

Reboot:

reboot

5. Install Perl (Required by cPanel Installer)

yum install perl -y

Perl is used internally by the cPanel installer. Missing it results in a failed install.


6. Download and Run the cPanel Installer

Create a directory for installation (optional but clean):

cd /home
mkdir cpanelinstall
cd cpanelinstall

Download the installer:

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

Run the installer:

sh latest

Now walk away. This process can take 30–60 minutes, depending on your server speed and bandwidth.

The installer will:

  • Fetch all required packages
  • Configure services like Apache, Exim, Dovecot
  • Install MySQL or MariaDB
  • Set up WHM/cPanel base services

7. Access WHM and Complete Setup

Once installed, access WHM using your browser:

https://your-server-ip:2087

Log in with your root username and password.

Post-Installation Wizard

You’ll walk through:

  • License agreement
  • Setting up contact info (email alerts)
  • Configuring hostname, IP addresses
  • Enabling nameservers (BIND or PowerDNS)
  • Choosing default services (Exim, Dovecot, MariaDB)

Pick your configurations carefully. You can change most later, but it’s best to get it right upfront.


8. Configure Firewall (Optional But Recommended)

If you’re running firewalld:

firewall-cmd --permanent --add-port=2087/tcp
firewall-cmd --permanent --add-port=2083/tcp
firewall-cmd --permanent --add-port=2086/tcp
firewall-cmd --permanent --add-port=2082/tcp
firewall-cmd --reload

These ports are for WHM, cPanel, and webmail access.

For advanced setups, consider CSF (ConfigServer Security & Firewall) — it integrates tightly with WHM.


9. Install a cPanel License

Unless you’re using a licensed image (e.g., from a hosting provider), you’ll need to activate your license:

/usr/local/cpanel/cpkeyclt

Or log in to WHM and enter your license key.

You can purchase a license from:


10. Enable AutoSSL

Free SSL certificates via Let’s Encrypt or Sectigo are built-in.

Go to:

WHM → SSL/TLS → Manage AutoSSL

  • Choose the provider (Let’s Encrypt recommended)
  • Enable for all users
  • Run a scan to install certificates

Now your sites and mail services will automatically use HTTPS and secure protocols.


11. Security & Tuning

Change SSH Port

To reduce brute-force attacks:

nano /etc/ssh/sshd_config

Change:

Port 22 → Port 2222 (or another unused port)

Then restart SSH:

systemctl restart sshd

Install CSF

CSF adds real-time firewall management and login tracking.

cd /usr/src
wget https://download.configserver.com/csf.tgz
tar -xzf csf.tgz
cd csf
sh install.sh

Access it in WHM under Plugins → ConfigServer Security & Firewall.


12. Monitor and Maintain

Log Locations

  • WHM logs: /usr/local/cpanel/logs/error_log
  • Apache: /etc/apache2/logs/ or /var/log/apache2/
  • Mail: /var/log/exim_mainlog
  • MySQL: /var/lib/mysql/hostname.err

Update Regularly

Keep the system up to date:

yum update -y

cPanel handles most service updates, but your OS packages still need attention.


Final Thoughts

Installing cPanel on a Linux server is straightforward—but only if your foundation is solid. A fresh OS, proper hostname, correct DNS, and basic hardening go a long way. Once installed, WHM provides a robust GUI to manage nearly every aspect of your server, but don’t rely solely on the interface. Know your logs, know your ports, and don’t leave security as an afterthought.

This guide walked you through a full, manual install without shortcuts. That’s intentional—because a seasoned admin understands that what you skip today turns into downtime tomorrow.

Web Hosting