Score:0

PHP can't write to /tmp folder anymore after Apache update

vn flag

Linux dist: Ubuntu 18.04.5 LTS Server version: Apache/2.4.29 PHP Version: 7.4.20 with PHP-FPM

Recently this server did an automatic upgrade of Apache and ever since PHP can't write to /tmp breaking many sites. PHP functions like tmpfile() and move_uploaded_file() are returning false. PHP's file_put_contents() and fopen() when attempting to write to that folder also fail. sys_get_temp_dir() returns /tmp

The permission on /tmp is drwxrwxrwt which I understand is correct. I tried df -h and the disk is not anywhere close to running out of space or anything like that. The open_basedir setting in php.ini is blank which is also correct.

Any thoughts on how to fix this?

Michael Hampton avatar
cz flag
Where did you get PHP from?
us flag
Anything/anyone can write to `/tmp`. So, IMO your PHP code is likely not trying to write to `/tmp` but somewhere else. Check `upload_tmp_dir` in php.ini? see - https://stackoverflow.com/a/16091596/503621
PHP Guru avatar
vn flag
My temporary solution to this was to just restart the process php-fpm until Apache eventually fixed the problem in a subsequent update. This was resolved a while ago. I am just posting about it now.
Score:0
cn flag

Has the PHP-FPM service been "updated" to use the PrivateTmp setting?

If it has, then even though you ask for /tmp, PHP will not give you /tmp!
See php-fpm temporary file path problem.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.