How to Install CPanel on CentOS 7

In September 2015, the product was launched. And it is available in the STABLE release tier now. The new brand cPanel 54 version is launched and it is available in the current release tier for this installation. Cpanel & WHM version 11.54+ supports the CloudLinux 7/RHEL 7/CentOS 7 operating systems for fresh installations.

In this article, I'm going to discuss about the features/Pre-requisites/installation of latest LTS release of cPanel & WHM 11.52 on CentOS 7 OS version. Before going to the installation, we can take a look on some of the new features of this release comparing the rest of the releases.

New features:

CloudLinux/RHEL/CentOS 7 support
Quota support & XFS file system
Amazon Linux AMI support
Webmail Branding
MultiPHP
Easy Apache 3 to 4 updates
Linux Container support
Common Mail providers tabs to WHM's Greylisting.

Network Requirements

Hostname should be a fully qualified domain name.
Should have a valid ipaddress, subnet address and default gateway
Ethernet device with a static IP & hostname
Disable OS Firewall
Hardware Requirements

Processor : 226 Mhz
RAM : Minimum 1GB ( 2GB recommended for smooth functioning)
Disk Space : Minimun 20 GB (40GB recommended for smooth functioning )
Disable Selinux

Need to edit the selinux configuration file located at : /etc/selinux/config

Modify the SELINUX parameter to disabled and reboot the server.

Installation steps followed for installing cPanel 11.52 on CentOS 7

Before installation make sure the server meets all the pre-requisites.

  1. Set hostname to a fully qualified domain

This is how we set the hostname for the server to a fully qualified domain name "server1.centos7-test.com" and confirm the hostname status once it is done.

root@server1 [~]# hostnamectl set-hostname server1.centos7-test.com –static
root@server1 [~]# hostnamectl status
Static hostname: server1.centos7-test.com
Icon name: computer-vm
Chassis: vm
Machine ID: 72863e389b584a4dab36fae7f3bffda2
Boot ID: 8bd4f714d7ba4ebf9d53f059d0a1fe8b
Virtualization: xen
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 4.1.5-x86_64-linode61
Architecture: x86-64
root@server1 [~]#

  1. Check for the IP addr, subnet addr and gateway

Make sure we have a static IP with a proper subnet mask and default gateway. In this case our IP address is 45.79.183.73 with a proper subnet mask and gateway.

root@server1 [~]# ifconfig
eth0: flags=4163 mtu 1500
inet 45.79.183.73 netmask 255.255.255.0 broadcast 45.79.183.255
inet6 fe80::f03c:91ff:fef1:78d9 prefixlen 64 scopeid 0x20
inet6 2600:3c03::f03c:91ff:fef1:78d9 prefixlen 64 scopeid 0x0
ether f2:3c:91:f1:78:d9 txqueuelen 1000 (Ethernet)
RX packets 38095 bytes 13241381 (12.6 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 41505 bytes 45527241 (43.4 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

  1. Check the OS, disk usage and RAM usage for the server

Our server is installed with CentOS 7.2, having a disk space of 20GB and around 1GB RAM. Please see the results of the hardware checks below:

OS version check:

# cat/etc/redhat-release

root@server1 [~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
root@server1 [~]#

Disk usage check:

# df-h

root@server1 [~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 20G 5.9G 14G 31% / devtmpfs 492M 0 492M 0% /dev
tmpfs 494M 0 494M 0% /dev/shm
tmpfs 494M 14M 480M 3% /run
tmpfs 494M 0 494M 0% /sys/fs/cgroup
/dev/loop0 662M 736K 627M 1% /tmp tmpfs 99M 0 99M 0% /run/user/0

RAM usage check:

free -m or cat /proc/meminfo

root@server1 [~]# free -m
total used free shared buff/cache available
Mem: 987 336 275 12 375 607
Swap: 511 1 510

  1. Disable Firewall

It is recommended to disable the OS firewalls before the cPanel & WHM installations. First of all we need to save the firewall rules and then stop the firewalld service. And make sure the service is disabled.

iptables-save > ~/firewall.rules systemctl stop firewalld.service systemctl disable firewalld.service

root@server1 [~]# systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)

Jan 09 06:50:28 server1.centos7-test.com systemd[1]: Stopped firewalld - dynamic firewall daemon.

  1. Disable Selinux

Modify the SELINUX parameter to disabled in /etc/selinux/config and reboot the server.
root@server1 [~]# cat /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=disabled
# SELINUXTYPE= can take one of these two values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection. SELINUXTYPE=targeted

  1. Installation of Perl

cPanel is programmed in Perl language. Hence, we need to install Perl prior to the cPanel installation if it isn't installed in the server before.

yum install -y perl

  1. Download/Install/Run cPanel/WHM script.

We need to download the cPanel installation script into the /home directory and run the script from there.

# cd /home

# curl -o latest -L https://securedownloads.cpanel.net/latest # sh latest

This is how we download and install the cPanel installation script from our server's home directory.

The script can take half an hour or more to complete the installation procedures.

Installation log

2016-01-07 07:15:51 227 ( INFO): cPanel install finished in 32 minutes and 14 seconds!
2016-01-07 07:15:51 964 ( INFO): Congratulations! Your installation of cPanel & WHM 11.52 is now complete. The next step is to configure your server.
2016-01-07 07:15:51 964 ( INFO):
2016-01-07 07:15:51 964 ( INFO): Before you configure your server, ensure that your firewall allows access on port 2087.
2016-01-07 07:15:51 964 ( INFO): On RHEL, CentOS, and CloudLinux systems, execute /scripts/configure_firewall_for_cpanel to accomplish this.
2016-01-07 07:15:51 964 ( INFO):
2016-01-07 07:15:51 964 ( INFO): After ensuring that your firewall allows access on port 2087, you can configure your server.
2016-01-07 07:15:51 964 ( INFO):
2016-01-07 07:15:51 964 ( INFO): 1. Open your preferred browser
2016-01-07 07:15:51 964 ( INFO):
2016-01-07 07:15:51 964 ( INFO): 2. Type https://45.79.183.73:2087 in the address bar
2016-01-07 07:15:51 964 ( INFO):
2016-01-07 07:15:51 964 ( INFO): 3. Enter the word root in the Username text box
2016-01-07 07:15:51 964 ( INFO):
2016-01-07 07:15:51 964 ( INFO): 4. Enter your root password in the Password text box
2016-01-07 07:15:51 964 ( INFO):
2016-01-07 07:15:51 964 ( INFO): 5. Click the Login button
2016-01-07 07:15:51 964 ( INFO):
2016-01-07 07:15:51 964 ( INFO): Visit http://go.cpanel.net/whminit for more information about first-time configuration of your server.
2016-01-07 07:15:51 964 ( INFO):
2016-01-07 07:15:51 964 ( INFO): Visit http://support.cpanel.net or http://go.cpanel.net/whmfaq for additional support
2016-01-07 07:15:51 964 ( INFO):
2016-01-07 07:15:51 964 ( INFO): Thank you for installing cPanel & WHM 11.52!
2016-01-07 07:15:51 835 ( WARN): !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  1. Adding ports 2087/2086 to the firewalld service

After completing the installation procedures, we need to ensure that our server allows the required service ports in the firewall.

[root@server1 zones]# firewall-cmd --zone=public --add-port=2087/udp success
[root@server1 zones]# firewall-cmd --zone=public --add-port=2086/udp success
[root@server1 zones]# firewall-cmd --zone=public --add-port=2086/tcp success
[root@server1 zones]# firewall-cmd --zone=public –add-port=2087/tcp

[root@server1 zones]# firewall-cmd --reload

If your server has enough resources, then it is always advised to disable the OS firewall and configure CSF/APF to ensure better security and allow all required cPanel service ports by default. I would recommend to go with CSF for a cPanel server.

CSF Installation steps:

wget http://configserver.com/free/csf.tgz

tar -xzf csf.tgz

cd csf & ./install.cpanel.sh

Access the WHM via the URL

You can access WHM using the URL https://server-hostname:2087 or http://server-hostname:2086

After accessing the URL mentioned above, you can put your username as root and its password to login.

Read through the terms and conditions & accept the license agreement.

Now you can do your initial configuration steps one by one as below:

  1. Setup Networking
  2. Setup IP address
  3. Nameservers
  4. Services
  5. Setup quotas

Visit http://go.cpanel.net/whminit for more information about first-time configuration of your server.

I believe this article will be a great help for you guys! Thank you for referring to this. I would appreciate your valuable comments for further improvements.