CommunityPlus+ sets PHP’s default log location to /QOpenSys/var/log/php_error.log. If you want to change this, edit /QOpenSys/etc/php/php.ini and change the value of error_log. PHP will write warnings, notices, and errors to the chosen location if permissions are set properly.


  • To ensure that PHP can write to the error log, be sure to grant appropriate permissions to the PHP user (usually QTMHHTTP for the web). If PHP doesn’t have permissions, error_log will be ignored. To let PHP create and write to the error log, set the following permissions for the PHP user:
    • At least *W on the log file (/QOpenSys/var/log/php_error.logby default) if it exists
    • At least *WX on the parent directory (/QOpenSys/var/log/by default)
    • At least *X on all directories above the parent directory (/QOpenSys/var/and up, by default–which should be already set).
  • After changing the value of error_log or any other values in php.ini, you’ll need to restart your web server for changes to take effect on your web site.
  • When you’ve finished, PHP can write timestamped error messages in your own PHP error log file.
  • error_log PHP manual page

If error_log isn’t set: for web sites, the FastCGI handler will let errors bubble up to the web server, generally causing error messages to end up in the website’s standard Apache error log.

Differences with per-site configuratiton

When you use the -I flag with siteadd (as of 0.5), the PHP configuration generated for the site will include placing the PHP error logs in the web server logs directory (for example, /www/mysite/logs.

Log rotation

Large log files are hard to work with. If your log file grows large, we recommend renaming it so that PHP will create an empty log file. This practice is called “Log Rotation.” Apache logs can be rotated using the LogMaint direcive, but what about PHP error logs?

The simplest way to rotate PHP error logs is with a CL program that renames your old log using a timestamp. Schedule the CL program to run weekly or so. We adapted a CL program provided by Zend’s Rod Flohr  to work well for CommunityPlus+ PHP (you can call it PHPLOGRTT):

RNM OBJ('/QOpenSys/var/log/php_error.log') +

With the logrotate tool being included in IBM i 7.4 TR3, logrotate may become a preferred approach in the future.

Advanced options and tips

The error_log value is used for both web and command line (CLI).

If running PHP from CLI, you can override error_log like so:

php -d error_log=value myscript.php

If you set an empty value for error_log (i.e. php -d error_log= myscript.php), errors will be output according to the PHP environment:

  • If you run PHP from a command line interactively, you’ll see the errors on your terminal. This can be a great troubleshooting technique.
  • If running from CLI, errors will be written to “standard error” output. You can redirect the standard error to a file with this bit of shell syntax:
php myscript.php 2> error.txt

As with the -d error_log=... trick, you can have a separate error log for each invocation.

If the error_log value is set to syslog, PHP errors will appear in the system operator log.