You are not logged in.
Hi Archers,
In one of my scripts, I need to use the PHP function tmpfile(). This creates a file in /tmp.
When I run this command in interactive php ($ php -a), the file is successfully created. When I start PHP's built-in web-server ($ php -S), and visit a page with the command, the file is also successfully created.
Now the problem: in my production setup I have Apache running with the PHP module. When I start that and visit a page that calls tmpfile(), nothing happens. No file gets created, and no error is shown.
I am using the stock httpd.conf and php.ini (I tried disabling open_basedir in php.ini, but that didn't do anything).
Any ideas? Thanks!
Edit: it seems that it is a problem with the location /tmp, and not necessarily tmpfile(). file_put_contents('/tmp/phptest','blablabla') also doesn't work.
Edit2: now that the issue is somewhat different, I found a few similar issues: one in the Arch forums, another somewhere else. none have a solution however...
Last edited by lonaowna (2014-11-21 18:04:26)
Offline
Have you tried adding /tmp to open_basedir instead of just commenting it out?
I recently setup nginx with php and php-fpm to use /tmp on a file upload, and you have to add /tmp to open_basedir.
Worked for me.
Also check your upload size, php.ini is set to 2M I believe.
More information would be appreciated.
Last edited by ackt1c (2014-11-21 16:39:58)
Offline
Hi, thanks for your reply!
By default, open_basedir already includes /tmp, so I had already tried that.
upload_max_filesize is indeed set to 2M by default, but as I don't upload the files, but create them locally on the server, I don't think that will affect the issue.
Offline
Group
Last edited by ackt1c (2022-11-05 13:40:17)
Offline
Apache uses a private /tmp directory, so the location would be /var/tmp/systemd-private-<uuid>-httpd.service-<whatever>/. However, this is only important if you want to access the files from outside apache.
Btw: The first answer on your link to stackoverflow will tell you the same.
Last edited by Tarqi (2014-11-21 18:01:10)
Knowing others is wisdom, knowing yourself is enlightenment. ~Lao Tse
Offline
Apache uses a private /tmp directory, so the location would be /var/tmp/systemd-private-<uuid>-httpd.service-<whatever>/. However, this is only important if you want to access the files from outside apache.
Thank you, that is it! After changing the systemd unit file, everything shows up as expected!
I found it quite confusing, as PHP kept reporting that the file was in /tmp, but I could not find it.
And indeed, I want to share the files between two programs (I need to download a file and store it temporarily, so I can print it with CUPS). I guess I need to create my own tmp, which has a fixed place and can be shared.
Thanks a lot for your reply!
Last edited by lonaowna (2014-11-21 18:02:48)
Offline