Comprehensive Guide to Troubleshooting and Managing cPanel/Linux Server Issues Print

  • 0

Prioritizing CloudLinux, PHP-FPM, Nginx, MySQL, Apache, cPanel, ModSecurity, and Kernel

 

Managing a cPanel/Linux server involves routine checks, debugging, logging, and monitoring to ensure the server runs smoothly and efficiently. This guide covers essential commands and techniques to help you maintain your server, identify common errors, and provide solutions.

1. cPanel Management

cPanel Status

Check the status of the cPanel service:
service cpanel status

Restart cPanel Service

Restart the cPanel service:
service cpanel restart
cd /etc/rc.d/init.d
./cpanel restart

cPanel Logs

View the last 100 lines of the cPanel logs:
tail -100 /usr/local/cpanel/logs/error_log
tail -100 /usr/local/cpanel/logs/access_log

Restart Tailwatch (cPanel service)

Restart Tailwatch service:
/scripts/restartsrv_chkservd

2. Apache Management

Apache Status

Check the status and processes of Apache:
ps aux | grep httpd
systemctl status httpd
service httpd status

Restart Apache

Restart Apache with hard restart if needed:
/scripts/restartsrv_httpd --restart --hard
/scripts/restartsrv_httpd

Apache Logs

View the last 100 lines of the Apache error logs:
tail -100 /etc/apache2/logs/error_log
tail -100 /var/log/apache2/error_log

Common Apache Errors and Solutions

Error:
AH00558: httpd: Could not reliably determine the server's fully qualified domain name
Solution:
- Edit the Apache configuration file:
vi /etc/httpd/conf/httpd.conf
- Add the following line:
ServerName localhost
- Restart Apache:
/scripts/restartsrv_httpd

3. MySQL Management

MySQL (MariaDB) Status
Check the status of MySQL/MariaDB:
service mysqld status
systemctl status mysqld
mysqladmin proc status

Restart MySQL

Restart MySQL service:
/scripts/restartsrv_mysql

MySQL Logs

View the last 100 lines of the MySQL error logs:
tail -100 /var/log/mysqld.log

Common MySQL Errors and Solutions

Error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'
Solution:
- Check if MySQL service is running:

systemctl status mysqld

- Restart MySQL service:
/scripts/restartsrv_mysql

4. PHP-FPM Management

PHP-FPM Status

Check the status of PHP-FPM:
/scripts/restartsrv_cpanel_php_fpm status

Restart PHP-FPM

Restart PHP-FPM services:
/scripts/restartsrv_cpanel_php_fpm
/scripts/restartsrv_apache_php_fpm

PHP-FPM Logs

View the last 100 lines of the PHP-FPM error logs:
tail -100 /usr/local/cpanel/logs/php-fpm/error.log

Common PHP-FPM Errors and Solutions

Error:
[ERROR] Unable to read FPM configuration file
Solution:
- Check the PHP-FPM configuration file for syntax errors:
php-fpm -t
- Correct any errors found in the configuration file:
vi /etc/php-fpm.conf
- Restart PHP-FPM:
/scripts/restartsrv_cpanel_php_fpm

 

5. Nginx Management

Nginx Status

Check the configuration and status of Nginx:
nginx -t
systemctl status nginx
apachectl -t

Restart Nginx

Restart Nginx with hard restart if needed:
/scripts/restartsrv_nginx --hard

Nginx Logs

View the last 100 lines of the Nginx error logs:
tail -100 /var/log/nginx/error.log

 

Common Nginx Errors and Solutions
Error:
nginx: [emerg] "server" directive is not allowed here
Solution:
- Validate Nginx configuration:
nginx -t
- Correct the configuration file:
vi /etc/nginx/nginx.conf
- Restart Nginx:
/scripts/restartsrv_nginx --hard

6. ModSecurity Management

ModSecurity Logs
Search for ModSecurity entries in logs:
grep "ModSecurity" /var/log/messages

 

Common ModSecurity Errors and Solutions

Error:
ModSecurity: Warning. Pattern match "(?i:(?:<\\s*?script|<\\s*?img|<\\s*?iframe))" at ARGS
Solution:
- Review the ModSecurity rule that triggered the warning:
vi /usr/local/apache/conf/modsec2.user.conf
- Modify or disable the specific rule as needed.

7. CloudLinux Management

 

CloudLinux Status

Check the status of the CloudLinux LVE Manager:
cldetect --version
Check the status of the CloudLinux CageFS:
cagefsctl --status
Check the status of the CloudLinux Database Governor:

service db_governor status

Restart CloudLinux Services
Restart CloudLinux LVE Manager:
service lvestats restart
Restart CloudLinux CageFS:
cagefsctl --force-update
Overall System Status
Check for failed systemd units:
systemctl --failed
View detailed system logs for errors:
journalctl -xe

8. Kernel Management

Kernel Messages

View the last 100 lines of kernel messages:
tail -100 /var/log/dmesg

Out of Memory (OOM) Errors

Identify OOM errors related to HTTP processes:
egrep "oom_reaper|out of memory" /var/log/messages | grep http | tail -25
egrep "out of memory" /var/log/messages | grep http | tail -25

Killed Process Errors

Identify killed process errors related to HTTP:
egrep "Killed process" /var/log/messages | grep http | tail -25
grep "Killed process" /var/log/messages
grep "oom-killer" /var/log/messages
Identifying Common Errors and Solutions

1. Apache Not Starting

Error:
AH00558: httpd: Could not reliably determine the server's fully qualified domain name
Solution:
- Edit the Apache configuration file:
vi /etc/httpd/conf/httpd.conf
- Add the following line:
ServerName localhost
- Restart Apache:
/scripts/restartsrv_httpd

 

2. MySQL Connection Issues

Error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'
Solution:
- Check if MySQL service is running:
systemctl status mysqld
- Restart MySQL service:
/scripts/restartsrv_mysql

 

3. PHP-FPM Fails to Start

Error:
[ERROR] Unable to read FPM configuration file
Solution:
- Check the PHP-FPM configuration file for syntax errors:
php-fpm -t
- Correct any errors found in the configuration file:
vi /etc/php-fpm.conf
- Restart PHP-FPM:
/scripts/restartsrv_cpanel_php_fpm

 

4. Nginx Configuration Errors

Error:
nginx: [emerg] "server" directive is not allowed here
Solution:
- Validate Nginx configuration:
nginx -t
- Correct the configuration file:
vi /etc/nginx/nginx.conf
- Restart Nginx:
/scripts/restartsrv_nginx --hard

 

5. High Memory Usage (OOM Errors)
Error:
Out of memory: Kill process
Solution:
- Identify the process causing high memory usage:
top
- Adjust Apache MaxRequestWorkers settings
 
vi /etc/httpd/conf/httpd.conf
Reduce the value of `MaxRequestWorkers`:
MaxRequestWorkers 150
- Restart Apache:
/scripts/restartsrv_httpd
6. SSH Issues
Error:
sshd: error: Bind to port 22 on 0.0.0.0 failed: Address already in use.
Solution:
- Check for another SSH service running:
netstat -tulpn | grep :22
- Kill the conflicting process or change the port:
vi /etc/ssh/sshd_config
Change the port number, then restart SSH:
sudo systemctl restart sshd.service

 

Conclusion
Regular monitoring and timely debugging are crucial to maintaining a healthy server environment. This guide provides essential commands and checks for cPanel/Linux servers. For more detailed guides and troubleshooting tips, refer to our [knowledge base](https://www.domainindia.com/knowledgebase) or submit a ticket for personalized support at https://www.domainindia.com/support.

Was this answer helpful?

« Back