Table of Contents#
- Prerequisites
- Preparing the Server
- Download and Install cPanel/WHM
- Post-Installation Steps
- Accessing cPanel
- Troubleshooting Common Issues
- 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 -yReboot the server if prompted to apply kernel updates:
rebootSet a Static IP Address#
cPanel requires a static IP for licensing and domain resolution. If your server uses DHCP, configure a static IP manually:
-
Edit the network interface file (replace
eth0with your interface name, e.g.,ens33):vi /etc/sysconfig/network-scripts/ifcfg-eth0 -
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 -
Restart the network service:
systemctl restart network
Verify the static IP with:
ip addr show eth0Configure 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.
-
Set the hostname:
hostnamectl set-hostname server.yourdomain.com -
Update
/etc/hoststo map the hostname to your static IP:vi /etc/hostsAdd this line (replace
192.168.1.100andserver.yourdomain.comwith your details):192.168.1.100 server.yourdomain.com server -
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:
-
Temporarily disable SELinux (takes effect immediately):
setenforce 0 -
Permanently disable SELinux (requires a reboot):
Edit/etc/selinux/config:vi /etc/selinux/configSet
SELINUX=disabled:SELINUX=disabled SELINUXTYPE=targeted -
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:
-
Install
firewalldif not already installed:yum install firewalld -y systemctl start firewalld systemctl enable firewalld -
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) -
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:
-
Log in to your server as root via SSH.
-
Download the cPanel installation script:
wget https://securedownloads.cpanel.net/latest -O cpanel-install.sh -
Run the script (this takes 30–60 minutes, depending on your server speed):
sh cpanel-install.shThe 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(replaceyour-server-ipwith 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.comandns2.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.logfor 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#
- cPanel Official Installation Guide
- CentOS 7 Network Configuration
- cPanel System Requirements
- Firewalld Documentation
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!