dotlinux blog

How to Install cPanel and WHM in CentOS 7

cPanel and WHM (Web Host Manager) are powerful, user-friendly tools for managing web hosting servers and websites. cPanel is designed for end-users, providing a graphical interface to manage domains, emails, files, and databases, while WHM is intended for server administrators to configure server settings, create cPanel accounts, and manage hosting packages.

If you’re running a CentOS 7 server and want to streamline server management, installing cPanel and WHM is an excellent choice. This guide will walk you through the entire process, from prerequisites to post-installation setup, ensuring you can get your server up and running with minimal hassle.

2026-05

Table of Contents#

  1. Prerequisites
  2. Preparing the Server
  3. Download and Install cPanel/WHM
  4. Post-Installation Steps
  5. Accessing cPanel
  6. Troubleshooting Common Issues
  7. References

Prerequisites#

Before installing cPanel and WHM, ensure your CentOS 7 server meets the following requirements:

  • Operating System: CentOS 7 (64-bit). Note: cPanel does not support CentOS 8/9, AlmaLinux, or Rocky Linux for this guide (check cPanel’s official docs for updates).
  • Hardware:
    • Minimum: 1 CPU core, 2 GB RAM, 20 GB disk space.
    • Recommended: 2+ CPU cores, 4+ GB RAM, 40+ GB SSD storage.
  • Network: A static public IP address (required for licensing and domain management).
  • Root Access: You must have full root access to the server (via SSH).
  • No Conflicting Software: Ensure no pre-installed web servers (Apache, Nginx), databases (MySQL, MariaDB), or control panels (Plesk, DirectAdmin) are present—cPanel will install its own stack.

Preparing the Server#

Update the System#

First, update your CentOS 7 system to ensure all packages are up-to-date. This reduces compatibility issues during installation:

yum update -y

Reboot the server if prompted to apply kernel updates:

reboot

Set a Static IP Address#

cPanel requires a static IP for licensing and domain resolution. If your server uses DHCP, configure a static IP manually:

  1. Edit the network interface file (replace eth0 with your interface name, e.g., ens33):

    vi /etc/sysconfig/network-scripts/ifcfg-eth0
  2. Update the file with your static IP details. Example configuration:

    TYPE=Ethernet
    BOOTPROTO=static
    NAME=eth0
    DEVICE=eth0
    ONBOOT=yes
    IPADDR=192.168.1.100  # Replace with your static IP
    NETMASK=255.255.255.0  # Subnet mask
    GATEWAY=192.168.1.1    # Gateway IP
    DNS1=8.8.8.8           # Google DNS (or your ISP’s DNS)
    DNS2=8.8.4.4
  3. Restart the network service:

    systemctl restart network

Verify the static IP with:

ip addr show eth0

Configure the Hostname#

cPanel requires a fully qualified domain name (FQDN) as the hostname (e.g., server.yourdomain.com). Avoid using localhost or bare domain names like yourdomain.com.

  1. Set the hostname:

    hostnamectl set-hostname server.yourdomain.com
  2. Update /etc/hosts to map the hostname to your static IP:

    vi /etc/hosts

    Add this line (replace 192.168.1.100 and server.yourdomain.com with your details):

    192.168.1.100 server.yourdomain.com server
  3. Verify the hostname:

    hostname
    # Output should be: server.yourdomain.com

Disable SELinux#

SELinux (Security-Enhanced Linux) can interfere with cPanel’s installation and functionality. Disable it temporarily and permanently:

  1. Temporarily disable SELinux (takes effect immediately):

    setenforce 0
  2. Permanently disable SELinux (requires a reboot):
    Edit /etc/selinux/config:

    vi /etc/selinux/config

    Set SELINUX=disabled:

    SELINUX=disabled
    SELINUXTYPE=targeted
  3. Reboot the server to apply changes:

    reboot

Set Up the Firewall#

cPanel uses specific ports for WHM, cPanel, and other services. Open these ports using firewalld:

  1. Install firewalld if not already installed:

    yum install firewalld -y
    systemctl start firewalld
    systemctl enable firewalld
  2. Open required ports:

    firewall-cmd --permanent --add-port=2082/tcp  # cPanel HTTP
    firewall-cmd --permanent --add-port=2083/tcp  # cPanel HTTPS
    firewall-cmd --permanent --add-port=2086/tcp  # WHM HTTP
    firewall-cmd --permanent --add-port=2087/tcp  # WHM HTTPS
    firewall-cmd --permanent --add-port=2095/tcp  # Webmail HTTP
    firewall-cmd --permanent --add-port=2096/tcp  # Webmail HTTPS
    firewall-cmd --permanent --add-port=22/tcp    # SSH
    firewall-cmd --permanent --add-port=80/tcp    # HTTP
    firewall-cmd --permanent --add-port=443/tcp   # HTTPS
    firewall-cmd --permanent --add-port=53/tcp    # DNS (TCP)
    firewall-cmd --permanent --add-port=53/udp    # DNS (UDP)
  3. Reload the firewall to apply changes:

    firewall-cmd --reload

Download and Install cPanel/WHM#

cPanel provides an automated installation script. Follow these steps to download and run it:

  1. Log in to your server as root via SSH.

  2. Download the cPanel installation script:

    wget https://securedownloads.cpanel.net/latest -O cpanel-install.sh
  3. Run the script (this takes 30–60 minutes, depending on your server speed):

    sh cpanel-install.sh

    The script will:

    • Install dependencies (Perl, Apache, MySQL/MariaDB, PHP, etc.).
    • Configure services.
    • Set up cPanel and WHM.

    Do not interrupt the installation! If it fails, check the log at /var/log/cpanel-install.log.

Post-Installation Steps#

Access WHM for the First Time#

Once installation completes, access WHM via a web browser:

  • URL: https://your-server-ip:2087 (replace your-server-ip with your static IP).
  • Username: root
  • Password: Use your server’s root password.

Accept the License Agreement#

On first login, you’ll see cPanel’s End User License Agreement (EULA). Read it, check the box, and click Continue.

Initial Setup Wizard#

The wizard will guide you through essential configurations:

1. Network Setup#

  • Hostname Verification: Confirm your FQDN (e.g., server.yourdomain.com).
  • Resolvers: Use Google DNS (8.8.8.8, 8.8.4.4) or your ISP’s DNS.

2. Nameserver Configuration#

Choose nameservers for your server (required for domain management). Options:

  • Use cPanel’s DNSOnly: For a dedicated DNS server (advanced).
  • Custom Nameservers: e.g., ns1.yourdomain.com and ns2.yourdomain.com (recommended for hosting).

Note: You’ll need to register these nameservers with your domain registrar (e.g., Namecheap, GoDaddy).

3. Service Configuration#

Select versions for services like:

  • Apache: Choose a version (e.g., 2.4).
  • PHP: Select a PHP version (e.g., 8.1) and extensions.
  • MySQL/MariaDB: Choose MariaDB (recommended) or MySQL.

4. Email Configuration#

Set up mail server settings (e.g., SMTP restrictions, spam filters).

5. Create a cPanel Account#

Finally, create your first cPanel user account (for managing websites). Fill in:

  • Domain: The primary domain (e.g., yourdomain.com).
  • Username: A unique username (e.g., user1).
  • Password: A strong password.
  • Package: Select a hosting package (e.g., default).

Accessing cPanel#

Once the WHM setup is complete, users can access cPanel via:

  • HTTP: http://yourdomain.com:2082
  • HTTPS: https://yourdomain.com:2083

Log in with the cPanel username and password created in WHM.

Troubleshooting Common Issues#

  • Installation Fails: Check /var/log/cpanel-install.log for errors (e.g., missing dependencies).
  • WHM/cPanel Not Accessible: Verify firewall rules (ports 2086/2087/2082/2083 are open) and SELinux is disabled.
  • Hostname Error: Ensure the hostname is an FQDN and resolves to your server’s IP (use nslookup server.yourdomain.com).

References#


By following these steps, you’ve successfully installed cPanel and WHM on CentOS 7. You can now manage your server, create cPanel accounts, and host websites with ease!