How to Log errors Vanilla PHP on Linux

3 months ago
13

📝 Description:

In this video, you'll learn how to securely log PHP errors on Linux using XAMPP or LAMPP. Whether you're debugging or building a serious PHP project, setting up a proper error log is crucial.

🛠️ What you’ll learn step by step:

1. Create a custom log folder and file.
2. Assign correct ownership to Apache (daemon or www-data).
3. Set secure file permissions to prevent exposure.
4. Configure PHP to log errors to your custom path.
5. Restart Apache to apply changes.
6. Trigger a test warning to verify everything works.
7. (Optional) Give yourself read access or join the Apache group.

🔐 We also show how to block web access to the log folder using .htaccess.

📁 Example log path:
/opt/lampp/htdocs/myproject/logs/error.log

⚠️ Bonus: Learn how to check which user Apache is actually running as (daemon vs www-data) using ps aux.

This tutorial is beginner-friendly but follows best practices for a secure setup.

🏷️ Hashtags:
#php #linux #xampp #lampp #phplogging #phpdeveloper #webdevelopment #apache #phpsecurity #logerrors #phptutorial #phponlinux #programming #errorhandling #phpdebugging

🔗 Source code:
https://keepsnip.com/source/how-to-log-errors-vanilla-php-on-linux

Loading comments...