Php – Apache & PHP folder permissions

apachedirectoryfile-permissionspermissionsPHP

Our PHP scripts create dynamic folders and files and we are having a permission issue. The folders were initially create using our ftpuser.
EG: Album (created by ftpuser) all subfolders and files in them have to be dynamically created. The apache user is the user when a new folder is created and then it cannot write anything to that folder for some reason.

The server is running with PHP safe mode OFF.

Whenever a folder is created by php script the user is apache and the permission for some reason shows as dr—-x–t

Thanks.

Best Answer

Find the place in the PHP where the folder is created. Typically, this will be:

mkdir( folderName );

Change the line to:

mkdir( folderName, 1755 );

Or, instead, add this line after the mkdir:

chmod( folderName, 1755 );

For more information, here's the PHP mkdir documentation.