Maintaining a cPanel/Linux server requires constant monitoring, optimization, and troubleshooting to ensure optimal performance, security, and uptime. This guide walks you through common server issues, their causes, and step-by-step troubleshooting methods to keep your server running efficiently. π
π 1. Diagnosing Server Performance Issues
π Checking Load Average & CPU Usage
High load average or excessive CPU usage can slow down your server significantly, affecting website speed, application performance, and user experience.
β Check System Load in Real-Time
Run the following commands to monitor system load:
uptime # Shows system load averages for the past 1, 5, and 15 minutes
top -c # Displays active processes with CPU and memory usage
htop # Interactive process viewer for better visualization
π Interpreting Load Average
-
Ideal Load: Should be less than the number of CPU cores.
-
Moderate Load: Equal to CPU cores β nearing saturation.
-
High Load: Exceeds CPU core count, indicating possible performance issues.
π Identify High-Resource-Consuming Processes
Use these commands to find which processes are consuming the most CPU:
top -o %CPU # Sort processes by CPU usage in real-time
ps aux --sort=-%cpu | head -10 # Show the top 10 highest CPU-consuming processes
π§ Find CPU-Intensive Processes by User
To check which user is consuming the most resources:
ps -eo user,%cpu,%mem,cmd --sort=-%cpu | head -10
For a detailed step-by-step guide on diagnosing server performance issues, refer to: π Diagnosing Server Performance Issues and Solutions π
π Advanced Performance Monitoring Tools
For deeper performance analysis, use SAR, iotop, and lsof:
β SAR (System Activity Reporter) - Historical Performance Analysis
SAR helps analyze CPU usage trends over time.
π Install SAR:
yum install sysstat -y # CentOS/RHEL
apt install sysstat -y # Ubuntu/Debian
π Monitor CPU usage every 5 seconds for 10 intervals:
sar -u 5 10
π Analyze Disk I/O bottlenecks:
sar -d 5 10
πΎ iotop - Monitor Disk I/O in Real-Time
When disk read/write operations are high, they can cause server slowdowns. iotop
shows which processes are consuming the most I/O.
π Install iotop:
yum install iotop -y # CentOS/RHEL
apt install iotop -y # Ubuntu/Debian
π Run iotop to monitor real-time disk usage:
iotop -o
π Find top I/O-consuming processes:
iotop -b -o | head -20
π lsof - List Open Files and Network Connections
If a server is under high load, checking open files and network connections can help identify issues.
π Install lsof:
yum install lsof -y # CentOS/RHEL
apt install lsof -y # Ubuntu/Debian
π Find open files for a process (Replace <PID>
with actual Process ID):
lsof -p <PID>
π Check active network connections:
lsof -i
This upgraded version of the section provides: β
Better readability
β
More diagnostic tools for deeper insights
β
Linked reference to a detailed guide
Let me know if you want further enhancements or additional troubleshooting methods! π
π 2. Memory (RAM) Usage & Swap Optimization
π§ Checking Memory Usage
Monitor your serverβs memory consumption using:
free -m
vmstat 1 5
If swap usage is high, your server may be running out of RAM.
π§ How to Optimize Memory Usage
-
Increase PHP-FPM max children to prevent excessive memory use per site.
-
Enable OPcache to reduce repeated script execution overhead.
-
Increase MySQL
innodb_buffer_pool_size
for better database efficiency.
β‘ 3. Slow Website & High Latency Troubleshooting
π Checking Website Performance
Use:
ping domain.com
traceroute domain.com
curl -I domain.com
Look for high response times or packet loss, which may indicate network issues.
Identify slow scripts using strace
or by enabling WordPress debug logs.
π More details on website speed troubleshooting: Why Is My Website Slow?
πΎ 4. Disk Usage & I/O Performance Issues
π Checking Disk Space & Usage
df -h
du -sh /home/*
If /var
or /tmp
is full, database crashes or mail issues may occur.
Delete unnecessary backups, logs, or cache files to free up space.
π Learn how to analyze excessive bandwidth & log usage: Log Analysis & Bandwidth Optimization
β 5. Troubleshooting Common cPanel Issues
π 403/404 Forbidden & Not Found Errors
Check file permissions:
find /home/user/public_html -type d -exec chmod 755 {} \;
find /home/user/public_html -type f -exec chmod 644 {} \;
Ensure the .htaccess
file isnβt blocking requests.
Verify ownership of files:
chown -R user:user /home/user/public_html
π DNS Issues (Domains Not Resolving Properly)
Check domain DNS settings:
dig domain.com
nslookup domain.com
Ensure nameservers are correct in /etc/resolv.conf
.
π₯ 6. MySQL & Database Issues
βοΈ Checking MySQL Service Status
systemctl status mariadb
mysqladmin processlist
If you see Too many connections
, increase max_connections
in my.cnf
.
Optimize slow queries by enabling MySQL slow query logs.
π Read more: Diagnosing & Fixing Slow MySQL Queries
π 7.Β PHP-FPM & Web Server Optimization: Boosting Server Performance
π Why PHP-FPM Matters for Server Performance
PHP-FPM (FastCGI Process Manager) is an advanced PHP handler designed to optimize high-performance applications by efficiently managing PHP processes. Unlike traditional PHP handlers (e.g., mod_php), PHP-FPM significantly reduces CPU and memory usage while improving the speed and responsiveness of dynamic websites.
β Key Benefits of PHP-FPM:
-
π Better Performance: PHP-FPM efficiently handles concurrent requests, reducing server load.
-
πΎ Lower Memory Consumption: Uses process pools to optimize RAM usage.
-
π― Fine-Grained Control: Customizable pools for different domains and applications.
-
π Smooth Scalability: Handles peak loads without service interruptions.
-
π₯ Increased Security: Runs processes under separate user accounts, improving isolation.
β‘ Optimizing Server Performance Using PHP-FPM
1οΈβ£ Tune PHP-FPM Configuration
The default PHP-FPM settings may not be optimized for a high-traffic shared server. Modify /etc/php-fpm.d/www.conf
or the respective pool configuration files in cPanel, DirectAdmin, or Webuzo.
πΉ Key Parameters to Optimize:
pm = dynamic
pm.max_children = 150
pm.start_servers = 20
pm.min_spare_servers = 10
pm.max_spare_servers = 50
pm.process_idle_timeout = 10s
pm.max_requests = 500
-
Dynamic Process Management: Adjusts worker processes based on demand.
-
Max Children: Controls how many PHP-FPM workers can run simultaneously.
-
Spare Servers: Maintains idle workers to handle sudden request spikes.
-
Process Timeout: Ensures efficient termination of inactive processes.
2οΈβ£ Enable OPcache for Faster PHP Execution
opcache.enable=1
opcache.memory_consumption=256
opcache.max_accelerated_files=100000
opcache.validate_timestamps=0
-
OPcache stores precompiled PHP scripts in memory, reducing processing time.
3οΈβ£ Adjust PHP-FPM Pools for Multiple Websites
Each website can have a separate pool for better resource management. Example for a separate domain:
[example.com]
user = example_user
group = example_group
listen = /run/php-fpm/example.com.sock
pm = ondemand
pm.max_children = 50
pm.process_idle_timeout = 30s
-
Separate pools prevent resource overuse by a single website.
4οΈβ£ Optimize Web Server Configuration
πΉ For Apache (cPanel & DirectAdmin):
<IfModule mod_proxy_fcgi.c>
<FilesMatch "\.php$">
SetHandler "proxy:unix:/run/php-fpm/example.com.sock|fcgi://localhost"
</FilesMatch>
</IfModule>
-
Integrates PHP-FPM with Apache for optimized execution.
πΉ For Nginx (Webuzo & Custom Setups):
location ~ \.php$ {
fastcgi_pass unix:/run/php-fpm/example.com.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
-
Enables efficient PHP handling using PHP-FPM and UNIX sockets.
π₯ Installation Guide for PHP-FPM in cPanel, DirectAdmin & Webuzo
πΉ Installing PHP-FPM on cPanel
-
Log in to WHM.
-
Navigate to Home > Software > EasyApache 4.
-
Click Customize on the currently installed profile.
-
Go to PHP Extensions, search for
phpXX-php-fpm
, and enable it. -
Click Review > Provision.
-
Enable PHP-FPM for each domain in MultiPHP Manager.
πΉ Installing PHP-FPM on DirectAdmin
-
SSH into your server as
root
. -
Edit DirectAdmin custom configuration:
cd /usr/local/directadmin/custombuild ./build set php_fpm yes ./build php n
-
Restart PHP-FPM:
systemctl restart php-fpm
πΉ Installing PHP-FPM on Webuzo
-
Log in to Webuzo Admin Panel.
-
Navigate to Server Settings > PHP Settings.
-
Enable PHP-FPM and select the desired PHP version.
-
Restart Webuzo services:
service webuzo restart
πTips for Maximum Performance
β
Keep PHP & PHP-FPM updated. β
Use UNIX sockets instead of TCP for faster local connections. β
Monitor resource usage with htop
, top
, or php-fpm -t
. β
Regularly analyze slow logs to optimize performance. β
Fine-tune server parameters based on real-world load patterns.
By optimizing PHP-FPM settings and integrating them with your web server, you can significantly improve performance, reduce resource consumption, and ensure a smooth experience for high-traffic websites. ππ¨
π‘οΈ 8. Server Security & Firewall Troubleshooting
π Checking CSF Firewall & IP Blocks
CSF (ConfigServer Security & Firewall) is a powerful tool for managing firewall rules and blocking malicious activity on your server. To check if an IP is blocked:
csf -g <blocked_ip>
grep "<blocked_ip>" /var/log/lfd.log
If a legitimate user is blocked, whitelist them:
csf -a <ip_address>
π Read more: Managing CSF Firewall Blocks
π₯ Preventing Brute Force Attacks
To prevent unauthorized access attempts, enable Login Failure Daemon (LFD) and monitor logs:
tail -f /var/log/lfd.log
Use Fail2Ban to block repeated login failures:
apt install fail2ban -y # Ubuntu/Debian
yum install fail2ban -y # CentOS/RHEL
systemctl enable --now fail2ban
Modify /etc/fail2ban/jail.local to protect SSH and other services:
[sshd]
enabled = true
maxretry = 3
findtime = 600
bantime = 3600
Restart Fail2Ban:
systemctl restart fail2ban
π Mitigating DDoS Attacks with CSF
To mitigate DDoS attacks, adjust CSF configurations:
csf --profile apply /etc/csf/csf.profile
csf --deny <attacker_ip>
Reduce connection limits to prevent excessive connections from a single IP:
echo "CT_LIMIT = "50"" >> /etc/csf/csf.conf
csf -r # Restart CSF
π Read more: Mitigating DDoS Attacks Using CSF
π Additional Security Measures
-
Disable Root Login via SSH to prevent unauthorized access:
nano /etc/ssh/sshd_config PermitRootLogin no systemctl restart sshd
-
Enable Two-Factor Authentication (2FA) for cPanel and WHM users.
-
Use ModSecurity (WAF) to block malicious requests:
a2enmod security2 # Enable ModSecurity (Apache) systemctl restart apache2
By implementing these security measures, you can significantly enhance the protection of your cPanel/Linux server against unauthorized access and attacks. π
π 9.Β Nginx (Reverse Proxy) Management in Popular Control Panels
Nginx is a powerful, high-performance web server and reverse proxy that can significantly enhance server performance when used correctly. Many popular control panels provide built-in or plugin-based Nginx support. This guide covers how to manage Nginx in cPanel, DirectAdmin, and Webuzo, including installation steps and optimization tips.
π Why Use Nginx as a Reverse Proxy?
-
π Performance Boost β Handles static content faster than Apache.
-
π Load Balancing β Efficiently distributes requests among backend servers.
-
π― Caching Capabilities β Reduces database queries and enhances speed.
-
π Enhanced Security β Provides protection against DDoS attacks.
π§ Installation & Management in Popular Control Panels
π οΈ cPanel (Nginx as Reverse Proxy)
cPanel does not include native support for Nginx, but you can install and manage it using Engintron or the official Nginx Manager Plugin.
β Installing Nginx on cPanel (Engintron Plugin)
cd /; bash <(curl -s https://raw.githubusercontent.com/engintron/engintron/master/engintron.sh)
-
Access WHM > Plugins > Engintron to configure Nginx settings.
π Managing Nginx in cPanel
systemctl restart nginx
systemctl status nginx
-
Restart and check the status of Nginx service.
-
Configure cache settings via Engintron for enhanced performance.
π οΈ DirectAdmin (Apache + Nginx or Pure Nginx)
DirectAdmin supports Apache + Nginx Hybrid Mode or Standalone Nginx.
β Installing & Configuring Nginx in DirectAdmin
cd /usr/local/directadmin/custombuild
./build set webserver nginx_apache # Or use 'nginx' for standalone
./build nginx_apache
./build rewrite_confs
-
DirectAdmin will configure Nginx as a proxy or a standalone web server.
π Managing Nginx in DirectAdmin
systemctl restart nginx
systemctl restart apache
-
Restart Nginx and Apache after making changes.
-
Adjust Nginx settings in DirectAdmin > Admin Settings.
π οΈ Webuzo (Nginx + Apache or Nginx Only)
Webuzo provides an easy way to manage Nginx from the panel or via CLI.
β Enabling Nginx in Webuzo
-
Log in to Webuzo Admin Panel.
-
Navigate to Server Settings > Web Server Settings.
-
Choose Apache + Nginx or Nginx Only.
-
Click Restart Web Server.
π Managing Nginx via CLI in Webuzo
service nginx restart
service httpd restart
-
Restart Nginx and Apache if required.
-
Configure caching in Webuzo > Nginx Settings.
π Choosing the Right Setup
-
π For High-Traffic Websites β Standalone Nginx is recommended.
-
π‘ For Compatibility with .htaccess β Use Apache + Nginx.
-
β¨ For Easy Control Panel Integration β Use the built-in Nginx options in cPanel, DirectAdmin, or Webuzo.
This guide provides an in-depth look at how to install, manage, and optimize Nginx as a Reverse Proxy in various hosting control panels. Let me know if you need further customizations! π
πΒ 10.Β Advanced Server Optimization: Managing cPanel, CloudLinux, PHP-FPM, Apache, MySQL & Nginx
Managing a cPanel/Linux server requires routine checks, debugging, logging, and monitoring to maintain smooth operation, optimal performance, and security. This guide covers essential commands, troubleshooting techniques, and solutions to keep your server running efficiently. π
π₯οΈ 1. cPanel Management
β Check cPanel Service Status
service cpanel status
π Restart cPanel Service
service cpanel restart
cd /etc/rc.d/init.d
./cpanel restart
π View cPanel Logs
tail -100 /usr/local/cpanel/logs/error_log
tail -100 /usr/local/cpanel/logs/access_log
π οΈ Restart Tailwatch Service (cPanel Service Monitoring)
/scripts/restartsrv_chkservd
π₯ 2. Apache (Web Server) Management
β Check Apache Status & Processes
ps aux | grep httpd
systemctl status httpd
service httpd status
π Restart Apache
/scripts/restartsrv_httpd --restart --hard
/scripts/restartsrv_httpd
π View Apache Logs
tail -100 /var/log/apache2/error_log
tail -100 /etc/apache2/logs/error_log
π¨ Fix Apache Server Name Error
Error: AH00558: httpd: Could not reliably determine the server's fully qualified domain name
Solution:
vi /etc/httpd/conf/httpd.conf # Edit the Apache configuration file
ServerName localhost # Add this line
/scripts/restartsrv_httpd # Restart Apache
π Read More: Mastering Apache Execution Models - The Ultimate Comprehensive Guide
πΎ 3. MySQL (MariaDB) Management
β Check MySQL Status
service mysqld status
systemctl status mysqld
mysqladmin proc status
π Restart MySQL
/scripts/restartsrv_mysql
π View MySQL Logs
tail -100 /var/log/mysqld.log
π¨ Fix MySQL Connection Issues
Error: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'
Solution:
systemctl status mysqld # Check if MySQL is running
/scripts/restartsrv_mysql # Restart MySQL service
β‘ 4. PHP-FPM Management
β Check PHP-FPM Status
/scripts/restartsrv_cpanel_php_fpm status
π Restart PHP-FPM
/scripts/restartsrv_cpanel_php_fpm
/scripts/restartsrv_apache_php_fpm
π View PHP-FPM Logs
tail -100 /usr/local/cpanel/logs/php-fpm/error.log
π¨ Fix PHP-FPM Configuration Error
Error: [ERROR] Unable to read FPM configuration file
Solution:
php-fpm -t # Check the PHP-FPM configuration for syntax errors
vi /etc/php-fpm.conf # Correct any errors found
/scripts/restartsrv_cpanel_php_fpm # Restart PHP-FPM
π 5. Nginx (Reverse Proxy) Management
β Check Nginx Configuration & Status
nginx -t
systemctl status nginx
apachectl -t
π Restart Nginx
/scripts/restartsrv_nginx --hard
π View Nginx Logs
tail -100 /var/log/nginx/error.log
π¨ Fix Nginx Configuration Error
Error: nginx: [emerg] "server" directive is not allowed here
Solution:
nginx -t # Validate Nginx configuration
vi /etc/nginx/nginx.conf # Correct the configuration file
/scripts/restartsrv_nginx --hard # Restart Nginx
π 6. ModSecurity (WAF) Management
β Check ModSecurity Logs
grep "ModSecurity" /var/log/messages
π¨ Fix ModSecurity Rule Error
Error: ModSecurity: Warning. Pattern match "(?i:(?:<\s*?script|<\s*?img|<\s*?iframe))" at ARGS
Solution:
vi /usr/local/apache/conf/modsec2.user.conf # Modify or disable the specific rule if necessary
π‘οΈ 7. CloudLinux Management
β Check CloudLinux Services
cldetect --version # Check CloudLinux LVE Manager status
cagefsctl --status # Check CageFS status
service db_governor status # Check Database Governor status
π Restart CloudLinux Services
service lvestats restart # Restart LVE Manager
cagefsctl --force-update # Restart CageFS
π οΈ Check Overall System Status
systemctl --failed # Check for failed systemd units
journalctl -xe # View detailed system logs for errors
π 8. Kernel Management
π View Kernel Messages
tail -100 /var/log/dmesg
π¨ Check for Out of Memory (OOM) Errors
egrep "oom_reaper|out of memory" /var/log/messages | grep http | tail -25
egrep "out of memory" /var/log/messages | grep http | tail -25
π¨ Identify Killed Process Errors
grep "Killed process" /var/log/messages
grep "oom-killer" /var/log/messages
β Conclusion
By following this guide, you can efficiently diagnose and fix common cPanel/Linux server issues. Regular monitoring, optimization, and security practices will ensure a stable and high-performing server. Bookmark this guide and keep your server running at peak performance! π
π Useful Links for Further Reading:
π Stay proactive! Regular maintenance and quick troubleshooting ensure a smooth and high-performing server. π―