在 CentOS 上,PHP 本身的“访问日志”通常不是单独存在的,而是依赖于 Web 服务器(如 Apache 或 Nginx)以及 PHP 错误日志。下面分情况说明:
# 默认位置
/var/log/httpd/access_log
# 查看实时日志
tail -f /var/log/httpd/access_log
/var/log/httpd/error_log
查看 php.ini:
php --ini
常见配置:
log_errors = On
error_log = /var/log/php_errors.log
查看:
tail -f /var/log/php_errors.log
/var/log/nginx/access.log
/var/log/nginx/error.log
# PHP-FPM 错误日志
/var/log/php-fpm/error.log
# 或
/var/log/php-fpm/www-error.log
/var/log/php-fpm/www-slow.log
grep -i "log" /etc/httpd/conf/httpd.conf
grep -i "log" /etc/nginx/nginx.conf
php -i | grep error_log
如果你能告诉我:
我可以给你更精确的日志路径和排查命令。