Keywords: LAMP/MAMP/WAMP - AWS - Technical issue - Permissions
### Cannot chmod a folder within /home/bitnami/apps/ from php due to www-data permission restrictions.
Hi! I want to change a directory permission to 0777 at php code execution time to allow a file to be created and saved within this folder, and then reverted to 0755.
I created a shell script file unlock.sh within the same location as the php file, and call the shell script as follows:
When the write the following command in the script file:
mkdir akeem and give the folder 0777 permissions, it successfully creates the new akeem directory. But when I write the following command:
sudo chmod **0777** /home/bitnami/apps/path/to/target/folder, it gives the following error sudo:
no tty present and no askpass program specified.
I went ahead and added
www-data ALL=(ALL) NOPASSWD: ALL to the /etc/sudoers file, then the error went away but then nothing happens.
When I run
./unlock.sh command from the terminal it works. I then logged in as www-data using
sudo su -l www-data -s /bin/bash and run
./unlock.sh From terminal and it still works.
So what is wrong with the
echo shell_exec(‘./unlock.sh’)? Why won’t it execute?
PHP chmod() function has never been a problem in the shared hosting packages I have previously used.