Search code examples
phplinuxapacheerror-logging

How do I know if my php process has right permissions to write to a file?


I turned on error logging in php.ini file.

error_log `/etc/httpd/logs/error_log`

error_reporting `22527`

I try triggering an error by using trigger_error() function. However, nothing gets written to the file. File is not even created. I'm guessing there are permission errors but how can I tell?


Solution

  • http://php.net/manual/en/function.is-writable.php

    bool is_writable ( string $filename )
    

    returns TRUE if the filename exists and is writable.

    That being said, logs generally go in /var/log/ or /var/apache2/log or somewhere other than /etc/ as

    /etc

    This is the nerve center of your system, it contains all system related configuration files in here or in its sub-directories

    If you mess something up in /etc/ it will be really, really bad.