How To Install cPanel on a Virtual Server Running Rocky or Centos Linux

Disable SELinux. You must disable SELinux to make your system compatible with cPanel & WHM. To disable SELinux security features, edit the /etc/selinux/config file to set the SELINUX parameter to disabled, and then reboot the server. The contents of the /etc/selinux/config file should resemble the following example:

dnf install nano
nano /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=enforcing
# SELINUXTYPE= can take one of three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
#SELINUXTYPE=targeted
SELINUXTYPE=disabled

Hostname Setup

cPanel is very picky about making sure that server that it is installed on has a Fully Qualified Domain Name. To that effect, we need to provide it with a valid hostname. Skipping this step will inevitably get you the following, very common, error:

2012-11-01 16:00:54 461 (ERROR): Your hostname () is not set properly. 
Please 2012-11-01 16:00:54 462 (ERROR): change your hostname to a fully qualified domain name, 
2012-11-01 16:00:54 463 (ERROR): and re-run this installer.

To remedy, set the hostname.

hostnamectl set-hostname host.example.com

Install Perl

Perl must exist on your server before the installation script for cPanel & WHM can run successfully. If Perl does not exist during installation, the cPanel & WHM installer attempts to install Perl via the yum -y install perl command. So let’s install it.

dnf install perl

Install cPanel

Let’s use screen to install. To start off, go ahead and install screen and wget:

dnf install epel-release -y
dnf install screen wget

Once screen is installed, start a new session running:

screen

After opening screen, you can proceed to install cPanel. Use this this command to install cPanel with WHM:

cd /home && curl -o latest -L https://securedownloads.cpanel.net/latest && sh latest

Then close out of screen. The script will continue running while in the background—even if you close out the of server.

In order to detach screen type:

Cntrl-a-d

To reattach to your screen you can use the command:

screen -r

Once cPanel finally installs, you can access the login by going to http://ipaddress:2087 (eg. https://12.34.45.678:2087) or domain (example.com:2087)

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.