How to install and setup cPanel with a software firewall (CSF) on CentOS 7

Preparing your environment

Login to your virtual machine via SSH using Putty (Windows) or Terminal (Mac) using the root user provided in your welcome email.
It is always recommended to update the servers repositories using the following command.
1
yum update
Copied!
Once the above command has finished we need to make sure we have set the hostname to a usable name. To check your current hostname run the command:
1
hostname
Copied!
You should see an output to the screen with the current hostname. If this isn't correct you can change the hostname by using the following command:
1
hostname YOUR-NEW-HOSTNAME
Copied!
We recommend a hostname format of: server.yourdomain.com uk.yourdomain.com web.yourdomain.com

Installing cPanel

Now that the environment is ready for cPanel/WHM we can run the following command to install the very latest
1
cd /home && curl -o latest -L https://securedownloads.cpanel.net/latest && sh latest
Copied!
It will take some time to complete the cPanel install but once completed you will be able to access WHM to complete the setup of cPanel.
Login to WHM by using your servers IP address and port 2086.
Example: http://0.0.0.0:2086/
You should now see the WHM login screen, enter your servers root login details and follow the on screen steps to complete your setup.

Installing ConfigServer Security & Firewall (csf)

The ConfigServer Security & Firewall (csf) service is very easy, once you have setup cPanel using the above steps access your virtual machine by SSH once again.
Copy and paste the block of commands into your SSH terminal to begin the setup.
1
cd /usr/src
2
rm -fv csf.tgz
3
wget https://download.configserver.com/csf.tgz
4
tar -xzf csf.tgz
5
cd csf
6
sh install.sh
Copied!
You should see a installation successful message. To test that services are running run the below test (optionial):
1
perl /usr/local/csf/bin/csftest.pl
Copied!
Now login into WHM and scroll down the menu on the left hand side of your screen, at the bottom you will now see a link to the ConfigServer Security & Firewall admin UI. Your IP will automatically be added to the firewalls whitelist.