问题
I am writing a PHP code that creates another PHP file with fopen and writes to it. It runs on most shared environments without any problem but in some old servers and customized servers the code fails to create file and write to it even though the folder permission is 755 as the PHP runs under the account 'nobody' and the folder owner is another user.
In shared servers the folder owner and the PHP both runs under same user and so there are no permission issues.
Can anyone help me out here with a solution please.....
Thank you All...
EDIT: This problem might have bugged many others including packages like Joomla, Drupa, etc. How do they get around this problem? Can anyone explain please. Thank you.
回答1:
If PHP runs as user 'nobody', but the folder you're trying to write in belongs to a different user, the only way to have write rights to that folder would be if 'nobody' is in the same group, of if the folder has permissions 777 (write rights for everyone).
回答2:
There is no direct solution to this problem. So the only solution was to show the user a relevant message and ask them to copy the files manually...
来源:https://stackoverflow.com/questions/6846549/creating-writing-to-a-file-with-permission-755-from-php-fails-as-php-runs-as