Report this

What is the reason for this report?

Trying to find php_error_log

Posted on December 2, 2016

Hi

Using Terminal, where can I find php_error_log?

I found another post on the forum that suggested using

find / -name php_error_log

I got a permission denied message. Then I remembered I need to put sudo before any commands, so I tried

sudo find / -name php_error_log

Terminal listed lots of files, but still output the permission denied message.

I’ve also tried looking at my info.php file, but the only reference I could find was error_log, that just says no value

Any help would be much appciated.



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi @smeehan

For starters, ou can use phpinfo(); function to ensure php.ini file is in use. But yes - probably it’s /etc/php/7.0/apache2/php.ini

To edit it (you almost got that) - use e.g.

sudo nano /etc/php/7.0/apache2/php.ini/php.ini

where nane is an editor, you can use “vim” or anything you want, like some gui editor.

p.s. After editing the file, you must do:

sudo service apache2 restart

For PHP to re-read the options.

Hi.

First look at /var/log/apache2/error.log

If you can’t see anything, then in you .php do

error_reporting(-1);

Yo can set the error log file name in php.ini doing:

error_log = "your_error_file.log"

Hope this helps.

Hi Konrado

Thanks for taking the time to reply :)

I created a new file called log.php it simply contains <?php error_reporting(-1); ?>

log.php is saved to /var/www/html

I used the locate command to find php.ini

locate php.ini

Terminal output:

  • /etc/php/7.0/apache2/php.ini
  • /etc/php/7.0/cli/php.ini
  • /usr/lib/php/7.0/php.ini-development
  • /usr/lib/php/7.0/php.ini-production
  • /usr/lib/php/7.0/php.ini-production.cli

Which one do I need to edit?

I assume it’s this one? /etc/php/7.0/apache2/php.ini

but when I run this: /etc/php/7.0/apache2/php.ini Terminal outputs: -bash: /etc/php/7.0/apache2/php.ini: Permission denied

I’m a beginner…

So, I tried: sudo /etc/php/7.0/apache2/php.ini Terminal outputs: sudo: /etc/php/7.0/apache2/php.ini: command not found

Any ideas?

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.