ConfigServer Security & Firewall (CSF) is a powerful and widely used firewall solution for Linux servers, providing an extensive range of security features. In this tutorial, we’ll cover how to install CSF on a cPanel server.
Before diving in, make sure you have root access to your server, as well as the cPanel and WHM installed.
How to Install CSF on a cPanel Server
Download and Install CSF
First, log in to your server as the root user using SSH. Once logged in, run the following commands to download and extract the CSF installation files:
cd /usr/src
wget https://download.configserver.com/csf.tgz
tar -xzf csf.tgz
Now, navigate to the extracted csf
directory and execute the installation script:
cd csf
sh install.sh
The installation process will take a few minutes. Once it’s complete, you’ll see a message indicating that CSF has been successfully installed.
Configure CSF for cPanel
To integrate CSF with your cPanel server, you need to enable the cPanel UI. Edit the CSF configuration file (/etc/csf/csf.conf
) using your preferred text editor:
nano /etc/csf/csf.conf
Find the line containing UI = "0"
and change it to UI = "1"
. Save and exit the file.
Now, restart CSF and its login failure daemon (LFD) to apply the changes:
csf -r
service lfd restart
Access CSF in WHM
With CSF installed and integrated with cPanel, you can now access its configuration options through WebHost Manager (WHM). Log in to your WHM and navigate to the Plugins section. You’ll find a new option called ConfigServer Security & Firewall.
Click on it, and you’ll see the CSF interface, where you can manage and configure various firewall settings.
Test and Enable CSF
Before enabling CSF, it’s essential to test its compatibility with your server. Run the following command:
perl /usr/local/csf/bin/csftest.pl
If the test returns no errors, you’re good to go. Edit the CSF configuration file again:
nano /etc/csf/csf.conf
Find the line containing TESTING = "1"
and change it to TESTING = "0"
. Save and exit the file.
Finally, restart CSF and LFD to apply the changes:
csf -r
service lfd restart
Congratulations! You’ve successfully installed and configured CSF on your cPanel server.
To further enhance your server’s security, check out our articles on how to protect your system from threats and how to secure Ubuntu system with firewall and AppArmor policies.
If you’re looking to improve your cPanel skills, explore our tutorials on how to install Softaculous on a cPanel server and how to install cPanel on AlmaLinux 8.
Happy server management!