I've installed Apache, PHP, and MySQL on Ubuntu 10.10 desktop edition, and it's working fine.
Except I have no clue where to look for Apache or PHP log files.

up vote 286 down vote accepted

By default, /var/log/apache2/error.log.

This can be configured in /etc/php5/apache2/php.ini.

  • Yep. got it. it was a bit different on windows. – Stann Nov 24 '10 at 19:38
  • 1
    Apache logs can be rotated, so you might want to check all error.log.* files – nuoritoveri Oct 6 '16 at 7:43
  • @misterben can you help me find enable the same error log for centOS 7? any idea? – Red Bottle May 15 '17 at 7:34
  • unix.stackexchange.com/a/269090/2799 has info for other distros – misterben Jun 7 '17 at 12:24
  • what if apache is not installed, just php? – mils Oct 17 '17 at 4:10

Check these settings in php.ini:

  1. error_reporting = E_ALL | E_STRICT (as recommended for development in php.ini)
  2. error_log = /var/log/php_errors.log
  3. Then create log file manually

    touch /var/log/php_errors.log
    chown www-data: /var/log/php_errors.log
    chmod +rw /var/log/php_errors.log
    

Now you can view PHP errors by this way

tail /var/log/php_errors.log

This is an agreeable solution to this issue for me.

  • 3
    would also need a step to restart the apache for settings to take effect – rbawaskar Oct 13 '14 at 10:32
  • Keep it tight: chmod 640 /var/log/php_errors.log – berbt Apr 4 '17 at 13:43

You can also define a specific error log file for each VirtualHost in Apache. If you have any VirtualHost defined in /etc/apache2/sites-available/ and enabled in /etc/apache2/sites-enabled (enable with sudo a2ensite [your-virtualhost-definition-file]), you can change the error log by adding the following line inside your VirtualHost config:

ErrorLog ${APACHE_LOG_DIR}/[your-vhost]-error.log

That might be useful if you have a lot of vhosts and want to split where they report the errors.

Also, you can watch your error log live by issuing the following command (adapt to your own log file if different from the default):

sudo tail -f /var/log/apache2/error.log

This is particularly useful when doing live debugging.

  • It works! If I comment out error_log = syslog in php.ini – mmv-ru Oct 23 '17 at 14:08

If Apache was setup with Webmin/Virtualmin there is a separate folder for each VirtualHost.

It is

~/logs

folder for each VirtualHost user.

These are two files:

~/logs/access_log

and

~/logs/error_log

So they are

/home/onedomain/logs/access_log

/home/onedomain/logs/error_log

/home/anotherdomain/logs/access_log

/home/anotherdomain/logs/error_log

...

etc.

To view log files for each particular domain login as VirtualHost owner user of that hostname and run

tail -f ~/logs/error_log

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.