Sunday 15 January 2012

php - Give Server Write Access To Folders -



php - Give Server Write Access To Folders -

i'm hosting lamp ec2 instance via amazon aws.

part of website allows users upload files. unfortunately, server not able store permanent copies in "uploads" folder because lacking necessary permissions.

a php script called store file "uploads" folder. upload fail while upload folder has standard 755 , 775 permissions. however, when alter folder permissions 777 (world permissions), works.

for obvious reasons, don't want utilize 777 world permissions. how can create server has permission write files "uploads" folder?

thanks guys.

this might issue ownership of upload folder. ownership of folder can checked next command ls -l sample output: -rw-r--r-- 1 root root 0 aug 31 05:48 demo.txt . here can seen both user of file root , grouping of file root. executing command within directory show permissions , ownership of files , folders in folder. lamp stack need create sure ownership apache user i.e. www-data , apache grouping 1 time again www-data. can done going in root folder of application , and executing command

chown -r www-data:www-data sample output: -rw-r--r-- 1 www-data www-data 0 aug 31 05:48 demo.txt

this recursively alter ownership of files , folders within root directory apache user , group. mutual cause of issue when have downloaded bundle or files , have done local or root user , apache not having permissions it. or have created directory manually. basic thought solve issue, might want consider execute command , alter ownership of "uploads" directory .

php amazon-web-services amazon-ec2 file-permissions folder-permissions

No comments:

Post a Comment