cPanel & WHM is a leading web hosting control panel that provides a graphical interface and automation tools designed to simplify the process of hosting a web site. This guide will walk you through the steps to install cPanel & WHM on a CentOS, CloudLinux, AlmaLinux, or RHEL server.
Prerequisites
- A fresh installation of a supported Linux distribution:
- 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. You can purchase one 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 can only be installed on a freshly installed operating system.
- The installation process will automatically install required services like Apache, PHP, MySQL, etc.
- Once installed, the only way to remove cPanel & WHM is by reformatting the server.
Step 1: Update Your System
Before starting, ensure your system packages are up-to-date.
sudo yum update -y
Step 2: Set the Hostname
Set a fully qualified domain name (FQDN) as the hostname for your server.
# Replace "server.example.com" with your desired hostname
sudo hostnamectl set-hostname server.example.com
Verify the hostname:
hostname -f
Step 3: Disable SELinux
cPanel requires SELinux to be disabled.
# Check SELinux status
sestatus
# Temporarily disable SELinux
sudo setenforce 0
# Permanently disable SELinux
sudo nano /etc/selinux/config
In the config file, set:
SELINUX=disabled
Save and close the file.
Step 4: Install Perl
Perl is required for the cPanel installation script.
sudo yum install perl -y
Step 5: Install cURL
cURL is needed to download the installation script.
sudo yum install curl -y
Step 6: Disable Firewall (Optional)
It's recommended to disable the firewall during installation to avoid any connectivity issues. You can re-enable it after installation.
# Stop the firewall
sudo systemctl stop firewalld
# Disable the firewall
sudo systemctl disable firewalld
Step 7: Download and Run the cPanel Installation Script
Navigate to the home directory and run the installation script.
cd /home
curl -o latest -L https://securedownloads.cpanel.net/latest
sudo sh latest
The installation process can take anywhere from 30 minutes to a couple of hours, depending on your server's performance and network speed.
Step 8: Complete the Installation
Once the installation is complete, you will see a message indicating that cPanel & WHM have been installed successfully.
Step 9: Access WHM (WebHost Manager)
Open your web browser and navigate to:
https://your_server_ip:2087
You might receive a security warning due to a self-signed SSL certificate. Proceed by adding an exception.
Step 10: Log In to WHM
Log in using the root user and your root password.
Step 11: Initial WHM Setup
After logging in, you'll need to complete the initial setup wizard:
- License Agreement: Accept the terms and conditions.
- Contact Information: Enter your email address and specify a contact SMS address if desired.
- Hostname Configuration: Confirm your server's hostname.
- Resolvers Configuration: Set up resolver IP addresses (default settings are usually acceptable).
- Network Configuration: Select the main network device (usually detected automatically).
- Set Up IP Addresses: Configure additional IP addresses if necessary.
- Nameservers: Choose your nameserver software (BIND or PowerDNS) and set up nameservers.
- Services Configuration: Configure FTP and mail services.
- Set Up Quotas: Enable file system quotas to limit disk space usage.
Step 12: Secure Your Server
After installation, it's important to secure your server:
- Re-enable the firewall:
# Start the firewall
sudo systemctl start firewalld
# Enable the firewall
sudo systemctl enable firewalld
- Configure firewall settings: Allow necessary ports for cPanel & WHM.
- Install and configure CSF (ConfigServer Security & Firewall): A popular firewall configuration plugin for cPanel.
- Keep your server updated: Regularly apply updates and patches.
- Use strong passwords: Ensure all accounts have strong, unique passwords.
Common cPanel Ports
You might need to allow the following ports through your firewall:
- 2087: WHM (SSL)
- 2086: WHM (non-SSL)
- 2083: cPanel (SSL)
- 2082: cPanel (non-SSL)
- 2096: Webmail (SSL)
- 2095: Webmail (non-SSL)
Conclusion
You have successfully installed cPanel & WHM on your Linux server. You can now start managing your web hosting environment through the WHM interface, create cPanel accounts, configure services, and host websites.