Find and review server logs
Managing a VPS or Dedicated server will require the review of logs when troubleshooting issues. This article will detail the common logs used and their respective locations.
Why would I need to look at log files?
- I don't know what's causing the issue.
- I have no idea where to start troubleshooting the issue.
- The issue only happens to some users.
- The "fix" I tried didn't resolve the issue.
Apache
Apache logs visitors to each site hosted on the server. A single visitor can generate multiple requests depending on the page. Most requests fall into 2 categories: GET (ie: show me an image) and POST (ie: logging into a site). The access logs also contain the timestamp, client IP address, and browser info.
cPanel Location:HTTP log:
/usr/local/apache/domlogs/$DOMAINHTTPS log:
/usr/local/apache/domlogs/$DOMAIN-ssl_log
Plesk Location:
HTTP logs:/var/www/vhosts/$DOMAIN/logs/access_logHTTPS logs:
/var/www/vhosts/$DOMAIN/access_ssl_logWhen should I review Apache Access logs?
- To see if a client’s connection makes it through the internet and firewalls and into Apache.
- If there is a problem with content editing in a CMS, the apache logs should still log a POST request. If there is no POST request, you should check the DNS, firewall(s), and the application.
- To check for DOS attacks by parsing data from these logs.
Most web service and application errors will be in the Apache Error log. The log will contain resource errors, PHP errors, and other errors to aid in troubleshooting.
Where can I find this log?
cPanel Location:
/usr/local/apache/logs/error_logPlesk Location:
/var/log/httpd/error_logUbuntu Location:
/var/log/apache2/error_logWhen should I review the Apache Error log?
The Apache error log should always be reviewed when troubleshooting a site-related issue. This includes internal server errors and intermittent performance issues.
Nginx
Nginx is often used as a web server (in place of Apache) to speed up the performance of a website. It is used, like PHP-FPM, to better utilize resources on heavy traffic sites.
Log location:/var/log/nginx/access.log
How can I access this log?
SSH
SSH allows you to access, view and manipulate the full log with tools such as vim or grep.
cPanelcPanel has nginx logs in the Metrics section under Raw Access for the site.
PleskPlesk will display nginx logs in the Logs section for the domain.
When would I need to review this log?- Your site is not working as intended.
- Your site is intermittently showing errors.
- Your site is slow or just spins and never loads.
Most web service and application errors will be in the nginx error log. The log will contain resource errors, PHP errors, and other errors to aid in troubleshooting.
Log location:/var/log/nginx/error.log
How can I review this log?
SSH allows you to access, view and manipulate the full log with tools such as vim or grep.
When should I review the nginx error log?The nginx error log should always be reviewed when troubleshooting a site-related issue. This includes internal server errors and intermittent performance issues.
PHP
The PHP Error log contains information about errors in specific PHP files, calls to missing files, or errors related to the configuration of PHP. PHP error logs are normally found within your site's files. You can use a PHPinfo() page to confirm the log location.
Where can I find this log?cPanel Location:
/home/cpanel_username/logs/$DOMAIN.php.error.logPlesk Location:
/var/www/vhosts/$DOMAIN/logs/error_logWhen should I review the PHP error log?
Anytime you are troubleshooting an issue that appears isolated to one or more PHP-based (like WordPress) sites, but not the entire server.
The PHP-FPM error log will contain errors related to the PHP-FPM service. There may be multiple logs if you utilize multiple versions of PHP.
Where can I find this log?cPanel Location:
/opt/cpanel/ea-phpXX/root/usr/var/log/php-fpm/error.logXX would be 73 for PHP-FPM 7.3.
CentOS/AlmaLinux w/Plesk location:
/var/www/vhosts/$DOMAIN/error_logUbuntu w/Plesk location:
/var/www/vhosts/$DOMAIN/logs/php-fpm_error.logWhen should I review the PHP-FPM log?
- Your site displays a 503 error.
- Your site is loading slowly or intermittently.
MySQL
MySQL error log will contain information about service failures, resource issues and crashed database tables.
Where can I find this log?For MySQL 5.5, 5.6 and MariaDB 10.2
/var/lib/mysql/$HOSTNAME.err
For mysql 5.7 and later
/var/log/mysqld.log
MariaDB 10.3 and later
/var/log/mariadb/mariadb.logWhen should I review the MySQL error log?
- The MySQL service will not run.
- The MySQL service is using excessive memory or CPU.
- Your database driven site (ie. WordPress) is slow.
- Your database driven site is unable to connect to MySQL.
Coming Soon!