You are not logged in.

#1 2023-04-30 14:51:39

jdarnold
Member
From: Medford MA USA
Registered: 2009-12-15
Posts: 485
Website

[Solved] PHP no longer able to write to folder

I am running nginx, php and php-fpm. I've been running the phpBB forums for a couple weeks. I recently updated my Arch so it is using php / php-fpm 8,2.5 and nginix 1.24 and now PHP can no longer write to the disk. Write permissions are not allowed any more. I wrote a simple php script to test this:

<?php                                                                                
                                                                                     
$filename = 'testing.txt';                                                           
                                                                                     
$functions = [                                                                       
  'is_readable',                                                                     
  'is_writable',                                                                     
  'is_executable'                                                                    
];                                                                                   
                                                                                     
foreach ($functions as $f) {                                                         
  echo 'The file ' . $filename . ' ';                                                
                                                                                     
  echo $f($filename) ?  '' : 'not';                                                  
                                                                                     
  echo ' ' . $f . '</p>';                                                            
                                                                                     
}                                                                                    

And I can change the permissions of testing,txt and see the changes to read and execute show up. But when I add write permission, it still says write is not allowed. What happened??

I seem to recall some kind of setting for php-fpm to allow it write access to the filesystem, but I don't recall what that was.

Last edited by jdarnold (2023-05-01 10:38:29)

Offline

#2 2023-05-01 06:12:16

tdtooke
Member
Registered: 2023-04-11
Posts: 245

Re: [Solved] PHP no longer able to write to folder

I don't use php-fpm but at work what I do is have a user group for all my web php stuff and the files that I might write to are owned by that group.  Maybe create a user and chown your files to be owned by that group.

Offline

#3 2023-05-01 10:14:58

schard
Forum Moderator
From: Hannover
Registered: 2016-05-06
Posts: 2,668
Website

Re: [Solved] PHP no longer able to write to folder

I think the php-fpm service has been hardened some time ago.
Try systemctl-editing the unit and adding the BBS's base dir to ReadWritePaths=


Inofficial first vice president of the Rust Evangelism Strike Force

Offline

#4 2023-05-01 10:38:10

jdarnold
Member
From: Medford MA USA
Registered: 2009-12-15
Posts: 485
Website

Re: [Solved] PHP no longer able to write to folder

schard wrote:

I think the php-fpm service has been hardened some time ago.
Try systemctl-editing the unit and adding the BBS's base dir to ReadWritePaths=

OMG, thank you thank you THANK YOU!

This was it exactly. The latest php-fpm update must have changed this, so it is actually pretty recent. But I'm back and working.

Offline

Board footer

Powered by FluxBB