Troubleshooting & Common Errors

Comprehensive Guide to Troubleshooting and Managing cPanel/Linux Server Issues

Published · Updated 13 min read
Knowledge base article
Contents (81 sections)

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:

code
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:

code
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:

code
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 
code
code

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:

code
yum install sysstat -y # CentOS/RHEL
apt install sysstat -y # Ubuntu/Debian

Monitor CPU usage every 5 seconds for 10 intervals:

code
sar -u 5 10

Analyze Disk I/O bottlenecks:

code
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:

code
yum install iotop -y # CentOS/RHEL
apt install iotop -y # Ubuntu/Debian

Run iotop to monitor real-time disk usage:

code
iotop -o

Find top I/O-consuming processes:

code
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:

code
yum install lsof -y # CentOS/RHEL
apt install lsof -y # Ubuntu/Debian

Find open files for a process (Replace <PID> with actual Process ID):

code
lsof -p <PID>

Check active network connections:

code
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:

code
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:

code
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

code
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:

code
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:

code
chown -R user:user /home/user/public_html

DNS Issues (Domains Not Resolving Properly)

Check domain DNS settings:

code
dig domain.com
nslookup domain.com

Ensure nameservers are correct in /etc/resolv.conf.


6. MySQL & Database Issues

Checking MySQL Service Status

code
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:

code
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

code
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:

code
[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):

code
<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):

code
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

  1. Log in to WHM.

  2. Navigate to Home > Software > EasyApache 4.

  3. Click Customize on the currently installed profile.

  4. Go to PHP Extensions, search for phpXX-php-fpm, and enable it.

  5. Click Review > Provision.

  6. Enable PHP-FPM for each domain in MultiPHP Manager.

Installing PHP-FPM on DirectAdmin

  1. SSH into your server as root.

  2. Edit DirectAdmin custom configuration:

code
cd /usr/local/directadmin/custombuild
./build set php_fpm yes
./build php n
  • Restart PHP-FPM:

  • code
    systemctl restart php-fpm

    Installing PHP-FPM on Webuzo

    1. Log in to Webuzo Admin Panel.

    2. Navigate to Server Settings > PHP Settings.

    3. Enable PHP-FPM and select the desired PHP version.

    4. Restart Webuzo services:

    code
    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:

    code
    csf -g <blocked_ip>
    grep "<blocked_ip>" /var/log/lfd.log

    If a legitimate user is blocked, whitelist them:

    code
    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:

    code
    tail -f /var/log/lfd.log

    Use Fail2Ban to block repeated login failures:

    code
    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:

    code
    [sshd]
    enabled = true
    maxretry = 3
    findtime = 600
    bantime = 3600

    Restart Fail2Ban:

    code
    systemctl restart fail2ban

    Mitigating DDoS Attacks with CSF

    To mitigate DDoS attacks, adjust CSF configurations:

    code
    csf --profile apply /etc/csf/csf.profile
    csf --deny <attacker_ip>

    Reduce connection limits to prevent excessive connections from a single IP:

    code
    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:

    code
    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:

  • code
    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.


    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.


    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)

    code
    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

    code
    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

    code
    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

    code
    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

    1. Log in to Webuzo Admin Panel.

    2. Navigate to Server Settings > Web Server Settings.

    3. Choose Apache + Nginx or Nginx Only.

    4. Click Restart Web Server.

    Managing Nginx via CLI in Webuzo

    code
    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

    code
    service cpanel status

    Restart cPanel Service

    code
    service cpanel restart
    cd /etc/rc.d/init.d
    ./cpanel restart

    View cPanel Logs

    code
    tail -100 /usr/local/cpanel/logs/error_log
    tail -100 /usr/local/cpanel/logs/access_log

    Restart Tailwatch Service (cPanel Service Monitoring)

    code
    /scripts/restartsrv_chkservd

    2. Apache (Web Server) Management

    Check Apache Status & Processes

    code
    ps aux | grep httpd
    systemctl status httpd
    service httpd status

    Restart Apache

    code
    /scripts/restartsrv_httpd --restart --hard
    /scripts/restartsrv_httpd

    View Apache Logs

    code
    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:

    code
    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

    code
    service mysqld status
    systemctl status mysqld
    mysqladmin proc status

    Restart MySQL

    code
    /scripts/restartsrv_mysql

    View MySQL Logs

    code
    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:

    code
    systemctl status mysqld # Check if MySQL is running
    /scripts/restartsrv_mysql # Restart MySQL service

    4. PHP-FPM Management

    Check PHP-FPM Status

    code
    /scripts/restartsrv_cpanel_php_fpm status

    Restart PHP-FPM

    code
    /scripts/restartsrv_cpanel_php_fpm
    /scripts/restartsrv_apache_php_fpm

    View PHP-FPM Logs

    code
    tail -100 /usr/local/cpanel/logs/php-fpm/error.log

    Fix PHP-FPM Configuration Error

    Error: [ERROR] Unable to read FPM configuration file

    Solution:

    code
    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

    code
    nginx -t
    systemctl status nginx
    apachectl -t

    Restart Nginx

    code
    /scripts/restartsrv_nginx --hard

    View Nginx Logs

    code
    tail -100 /var/log/nginx/error.log

    Fix Nginx Configuration Error

    Error: nginx: [emerg] "server" directive is not allowed here

    Solution:

    code
    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

    code
    grep "ModSecurity" /var/log/messages

    Fix ModSecurity Rule Error

    Error: ModSecurity: Warning. Pattern match "(i:(:<\s*script|<\s*img|<\s*iframe))" at ARGS

    Solution:

    code
    vi /usr/local/apache/conf/modsec2.user.conf # Modify or disable the specific rule if necessary

    7. CloudLinux Management

    Check CloudLinux Services

    code
    cldetect --version # Check CloudLinux LVE Manager status
    cagefsctl --status # Check CageFS status
    service db_governor status # Check Database Governor status

    Restart CloudLinux Services

    code
    service lvestats restart # Restart LVE Manager
    cagefsctl --force-update # Restart CageFS

    Check Overall System Status

    code
    systemctl --failed # Check for failed systemd units
    journalctl -xe # View detailed system logs for errors

    8. Kernel Management

    View Kernel Messages

    code
    tail -100 /var/log/dmesg

    Check for Out of Memory (OOM) Errors

    code
    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

    code
    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.

    Note: CentOS has reached end-of-life. If you are setting up a new server, we recommend using AlmaLinux or Rocky Linux as a drop-in replacement. The commands and procedures in this article apply equally to AlmaLinux and Rocky Linux.

    Was this article helpful?

    Your answer helps us decide what to improve next.

    Still need help? Open a support ticket and our team will reply.

    Prefer an app? Add this site to your home screen.Get the app