For anyone looking to improve the performance of web servers and provide customers with faster, more stable service, WHM/cPanel optimization is a critical step. Incorrect settings can lead to server resources being exhausted, slowdowns, and crashes. In this article, I will explain in detail all the steps you need to optimize your WHM/cPanel server from A to Z.
1. Server Software and Hardware Requirements
-
CPU: Should have at least 4 cores.
-
RAM: At least 8 GB, preferably 16 GB+.
-
Disk: NVMe or SSD is preferred.
-
Operating System: CentOS Stream, AlmaLinux, or CloudLinux is recommended.
2. Preparations Before WHM/cPanel Installation
-
Connect to the server with root.
-
Fully update the server:
yum update -y
-
Define the hostname (server name):
hostname server.yourdomain.com
-
Use a static IP address.
3. WHM Basic Settings
-
Disable unnecessary features from the "Tweak Settings" section.
-
Deactivate FTP usage, prefer SFTP.
-
Increase the minimum password length.
-
Activate SMTP Restrictions (prevents spam bots).
-
Activate PHP-FPM usage (for speed and stability).
4. Apache Web Server Optimization
-
Recommendation instead of Apache: Use LiteSpeed.
-
If Apache must be used, the following settings should be made:
-
KeepAlive: ON
-
MaxKeepAliveRequests: 100
-
KeepAliveTimeout: 3 seconds
-
-
Activate mod_deflate and mod_expires extensions (gzip compression + browser cache).
5. PHP Settings
-
Keep the PHP version up to date (minimum 8.1 is recommended).
-
PHP memory_limit: 512M
-
PHP upload_max_filesize: 128M
-
PHP post_max_size: 128M
-
PHP max_execution_time: 300
6. MySQL/MariaDB Optimization
-
MariaDB is recommended (faster and more optimized).
-
Optimize the settings in the /etc/my.cnf file:
[mysqld]
max_connections = 500
query_cache_size = 64M
query_cache_type = 1
tmp_table_size = 256M
max_heap_table_size = 256M
innodb_buffer_pool_size = 1G
-
Analyze with scripts like MySQLTuner and make adjustments according to the recommendations:
perl mysqltuner.pl
7. Cache Mechanisms
-
Use Redis or Memcached for WordPress sites.
-
Enable Redis from the "Service Manager" section in WHM.
-
Choose the correct cache plugins: LiteSpeed Cache, WP Rocket, etc.
8. CloudLinux and CageFS Usage
-
You can assign separate resource limits to each user using CloudLinux.
-
You can isolate users with CageFS and increase server security.
9. E-Mail Optimization
-
Set limits in Exim settings:
-
Daily mail sending limit: 500 (for each user)
-
-
Be sure to define DKIM, SPF, and DMARC records via DNS.
-
Protect inboxes using RBL lists (such as Spamhaus).
10. Security Settings
-
Install and activate CSF Firewall:
yum install csf -y
cd /etc/csf
sh install.sh
-
Activate ModSecurity.
-
Activate cPHulk brute force protection.
-
Restrict Root SSH access, only allow specific IP addresses.
11. Backup Optimization
-
From WHM "Backup Configuration" section:
-
Select Incremental backup.
-
Set up automatic backups to an external server (Google Drive, SFTP).
-
Create weekly and monthly backup plans.
-
12. Monitoring (Tracking and Alarm System)
-
Monitor CPU, RAM, and disk usage in real-time by installing the Munin Monitoring plugin.
-
You can use more advanced monitoring software such as Zabbix or Netdata.
13. Log Tracking and Cleaning
-
Unnecessary log files should not grow. Set up automatic cleaning with "logrotate".
14. Extra Improvements
-
Activate Swap memory (for RAM saving).
-
If IPv6 is not used, turn it off.
-
Make adjustments in the /etc/sysctl.conf file for TCP optimizations.
15. SSL Certificates
-
Define SSL for all domain names using Let's Encrypt or AutoSSL.
16. WHM and cPanel Updates
-
Activate automatic updates.
-
Select "Stable" as the "Release Tier".
Conclusion: By following these steps, you can bring your WHM/cPanel server to maximum performance, both lighten your own workload and increase customer satisfaction.
Remember, a server's speed depends not only on its hardware but also on software optimizations!