Introduction
cPanel & WHM is a leading web hosting control panel that provides a graphical interface and automation tools to simplify web hosting management. It is widely used in the hosting industry for its user-friendly interface and powerful features. This guide will walk you through the step-by-step installation of cPanel & WHM on CentOS, CloudLinux, AlmaLinux, and RHEL.
Prerequisites
Before you begin, ensure your server meets the following requirements:
A fresh installation of one of the following supported Linux distributions:
- CentOS 7 or 8
- CloudLinux 7 or 8
- AlmaLinux 8
- Red Hat Enterprise Linux (RHEL) 7 or 8
Root access to the server.
A valid cPanel license (purchase from the cPanel website).
A fully qualified domain name (FQDN) set as the hostname.
Minimum 1 GB RAM (2 GB recommended).
At least 20 GB of available disk space.
Important Notes:
- cPanel & WHM must be installed on a freshly installed operating system.
- The installation process will automatically install services such as Apache, PHP, and MySQL.
- Uninstalling cPanel is not possible without reformatting the server.
Step-by-Step cPanel Installation
Step 1: Update Your System
Before installing cPanel, update your system’s package list:
sudo yum update -y
Step 2: Set the Hostname
Set a fully qualified domain name (FQDN) as your server’s hostname.
sudo hostnamectl set-hostname server.example.com
Verify the hostname:
hostname -f
Step 3: Disable SELinux
cPanel requires SELinux to be disabled for proper operation.
Check the current SELinux status:
sestatus
Temporarily disable SELinux:
sudo setenforce 0
Permanently disable SELinux:
sudo nano /etc/selinux/config
Find the line:
SELINUX=enforcing
Change it to:
SELINUX=disabled
Save and exit the file (CTRL + X
, then Y
, then ENTER
).
Step 4: Install Perl
cPanel relies on Perl for installation.
sudo yum install perl -y
Step 5: Install cURL
cURL is required to download the cPanel installation script.
sudo yum install curl -y
Step 6: Disable Firewall (Optional)
To avoid connectivity issues during installation, temporarily disable the firewall:
sudo systemctl stop firewalld
sudo systemctl disable firewalld
After installation, re-enable the firewall and configure it properly.
Step 7: Download and Run the cPanel Installation Script
Navigate to the home directory:
cd /home
Download the latest cPanel installation script:
curl -o latest -L https://securedownloads.cpanel.net/latest
Run the installation script:
sudo sh latest
Note: The installation process can take 30 minutes to a few hours depending on your server’s specifications.
Step 8: Access WHM (WebHost Manager)
Once installation is complete, access WHM (WebHost Manager) through your web browser:
https://your_server_ip:2087
You might see a security warning due to a self-signed SSL certificate. Simply proceed by adding an exception.
Step 9: Log in to WHM
Use the root user and root password to log in.
Step 10: Complete WHM Initial Setup
After logging into WHM, follow the setup wizard:
- License Agreement – Accept the terms and conditions.
- Contact Information – Enter your email address and optional SMS contact.
- Hostname Configuration – Confirm the server hostname.
- Resolvers Configuration – Set up DNS resolver IPs (default is fine).
- Network Configuration – Select the main network device (auto-detected).
- Set Up IP Addresses – Add extra IP addresses if needed.
- Nameservers – Choose a nameserver software (BIND or PowerDNS) and configure nameservers.
- Services Configuration – Configure FTP and mail services.
- Set Up Quotas – Enable disk quotas if necessary.
Step 11: Secure Your cPanel Server
After installation, securing your server is essential:
Re-enable the firewall
sudo systemctl start firewalld
sudo systemctl enable firewalld
Allow Required Ports
Configure your firewall to allow the following cPanel & WHM ports:
Service | Port |
---|---|
WHM (SSL) | 2087 |
WHM (non-SSL) | 2086 |
cPanel (SSL) | 2083 |
cPanel (non-SSL) | 2082 |
Webmail (SSL) | 2096 |
Webmail (non-SSL) | 2095 |
Install CSF (ConfigServer Security & Firewall)
CSF is a popular firewall plugin for cPanel security:
sudo yum install csf -y
Regularly Update Your Server
sudo yum update -y
Use Strong Passwords
Ensure all root and user passwords are strong and unique.
Conclusion
You have successfully installed cPanel & WHM on your Linux server! You can now manage your web hosting environment, create cPanel accounts, configure services, and host websites.
Need further customization? Explore WHM settings to optimize server performance.
Stay secure by monitoring server logs and keeping software updated.
For more advanced configurations, visit the official cPanel documentation: https://docs.cpanel.net/.