When your Lighttpd server isn't logging errors properly, the first place to check is the server.errorlog
directive. In your case, you have conflicting configurations:
# Main config
server.errorlog = "/home/lxadmin/httpd/lighttpd/error.log"
# Included config
server.errorlog = "/home/httpd/mywebsite.com/stats/mywebsite.com-error_log"
The last declaration wins, so only the included config's path is active. This explains why your error.log remains empty while the mywebsite.com-error_log might not be working due to permission issues.
Here's the correct way to configure error logging in Lighttpd:
# Ensure the error log path is writable by the lighttpd user
server.errorlog = "/var/log/lighttpd/error.log"
# Set appropriate permissions (run as root)
$ sudo touch /var/log/lighttpd/error.log
$ sudo chown lighttpd:lighttpd /var/log/lighttpd/error.log
$ sudo chmod 640 /var/log/lighttpd/error.log
For PHP FastCGI errors, you need additional configuration:
fastcgi.debug = 1
fastcgi.server = ( ".php" => ((
"bin-path" => "/usr/bin/php-cgi",
"socket" => "/tmp/php.socket",
"max-procs" => 12,
"bin-environment" => (
"PHP_FCGI_CHILDREN" => "2",
"PHP_FCGI_MAX_REQUESTS" => "500",
"PHP_FCGI_ERROR_LOG" => "/var/log/lighttpd/php-errors.log"
),
"broken-scriptfilename" => "enable"
)))
If errors still don't appear:
- Verify lighttpd has write permissions to the log directory
- Check for syntax errors in your config:
$ lighttpd -tt -f /etc/lighttpd/lighttpd.conf
- Enable full debugging temporarily:
debug.log-request-handling = "enable" debug.log-condition-handling = "enable"
- Restart lighttpd after changes:
$ sudo service lighttpd restart
For better error tracking, consider these enhancements:
# Log errors with timestamps
server.errorlog-use-syslog = "enable"
server.syslog-facility = "local6"
# Rotate logs to prevent them from growing too large
server.errorlog = "|/usr/sbin/rotatelogs /var/log/lighttpd/error.%Y%m%d.log 86400"
# Capture PHP errors in separate log
$HTTP["url"] =~ "\.php$" {
setenv.add-environment = ("PHP_ERROR_LOG" => "/var/log/lighttpd/php_errors.log")
}
When troubleshooting Lighttpd with FastCGI on CentOS 5, the most frustrating scenario is encountering HTTP 500 errors without any corresponding entries in the error logs. The configuration snippets you've shared reveal several potential points where logging might fail silently.
For comprehensive error logging, these directives must work in harmony:
# Essential logging modules
server.modules += ("mod_accesslog")
# Debug settings (temporarily enable for troubleshooting)
debug.log-file-not-found = "enable"
debug.log-condition-handling = "enable"
# Log file paths with proper permissions
server.errorlog = "/var/log/lighttpd/error.log"
accesslog.filename = "/var/log/lighttpd/access.log"
From your configuration, I notice two overlapping error log paths which creates ambiguity:
# Conflicting declarations (remove one)
server.errorlog = "/home/lxadmin/httpd/lighttpd/error.log"
server.errorlog = "/home/httpd/mywebsite.com/stats/mywebsite.com-error_log"
Your FastCGI setup needs these enhancements for proper error reporting:
fastcgi.debug = 1
fastcgi.server = ( ".php" => ((
"bin-path" => "/usr/bin/php-cgi",
"socket" => "/tmp/php.socket",
"max-procs" => 12,
"bin-environment" => (
"PHP_FCGI_CHILDREN" => "2",
"PHP_FCGI_MAX_REQUESTS" => "500",
"PHP_FCGI_ERROR_LOG" => "/var/log/lighttpd/php-errors.log"
),
"broken-scriptfilename" => "enable"
)))
Run these commands to verify and correct permissions:
# Create log directory if missing
mkdir -p /var/log/lighttpd
# Set proper ownership
chown lighttpd:lighttpd /var/log/lighttpd
chmod 755 /var/log/lighttpd
# Test configuration
lighttpd -tt -f /etc/lighttpd/lighttpd.conf
For complete error visibility, implement this comprehensive logging strategy:
# In lighttpd.conf
$HTTP["host"] == "mywebsite.com" {
server.errorlog = "/var/log/lighttpd/mywebsite-error.log"
accesslog.filename = "/var/log/lighttpd/mywebsite-access.log"
# Capture FastCGI stderr
fastcgi.server = ( ".php" => ((
"bin-path" => "/usr/bin/php-cgi",
"socket" => "/tmp/php.socket",
"bin-copy-environment" => ("PATH", "SHELL", "USER"),
"broken-scriptfilename" => "enable",
"x-sendfile" => "disable"
)))
}
- Verify Lighttpd runs under correct user (ps aux | grep lighttpd)
- Check SELinux context for log files (ls -Z /var/log/lighttpd)
- Test PHP separately (php-cgi -v)
- Monitor logs in realtime (tail -f /var/log/lighttpd/error.log)