I've designated the tmp directory to be
/tmp (at the Drupal admin path
admin/config/media/file-system). This setting is confirmed by running
The permissions of
/tmp/drupal_debug.txt (including SELinux settings, which I learned about here) are like so:
$ ls -ltZ /tmp/ -rwxrwxrwx. apache apache unconfined_u:object_r:httpd_sys_rw_content_t:s0 drupal_debug.txt
Further, if I run
dd("Foo") from within the PHP CLI tool
phpsh using the drush integration to get a bootstrapped Drupal environment, then I'm able to use
dd() to print to this file without issue. Is there something additional I need to do to allow Apache to write to this file?
There are no errors in the Apache log, and notably, the issue persists even when I run
sudo setenforce 0.
Another interesting point: the PHP test snippet from this StackOverflow question returns "Success" when I run it from
devel/php, in other words Drupal does feel it can write to an arbitrary file in
/tmp. However, if I modify the code to the following form:
$handle = fopen("/tmp/drupal_debug.txt", "x"); if ($handle) echo "Success!"; else print_r(error_get_last());
then I get this warning, and no success message:
Warning: fopen(/tmp/drupal_debug.txt): failed to open stream: File exists in eval() (line 1 of /srv/www/decipher-storyscope/public_html/decipher/7f/profiles/storyscope/modules/contrib/devel/devel.module(1285) : eval()'d code).
This is true even if I delete the
However, as discussed in the comments, no file is created when running this snippet over the web, whereas, an empty file is created if I run the same snippet from the PHP command line.
NB. The function works fine when the code is installed and
dd() called on Ubuntu.