Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the proper permissions for an upload folder with PHP/Apache?

Tags:

php

apache

upload

Sorry for the basic question - I'm a .NET developer and don't have much experience with LAMP setups.

I have a PHP site that will allow uploads to a specific folder. I have been told that this folder needs to be owned by the webserver user for the upload process to work, so I created the folder and then set permissions as such:

chown apache:apache -R uploads/ chmod 755 -R uploads/ 

The only problem now is that the FTP user can not modify the uploaded files at all.

Is there a permission setting that will allow me to still upload files and then modify them later as a user other than the webserver user?

like image 538
Raleigh Buckner Avatar asked Aug 14 '08 13:08

Raleigh Buckner


People also ask

What permissions should Apache have?

*Apache privilege separation By default, all Apache processes run as the same www-data user, so any Apache process can read files from all other websites configured on the same server, and sometimes even make changes. Any user who can get Apache to run a script can gain the same access that Apache itself has.

How do I give Apache permission to a folder?

There may be some cases where you have to give the web server write permission to a file, or to a directory - this can be achieved by doing sudo chmod g+w /var/www/html/PATH (where PATH is the path to the file or folder in the directory structure where you need to apply the write permissions for the web server).


1 Answers

You can create a new group with both the apache user and FTP user as members and then make the permission on the upload folder 775. This should give both the apache and FTP users the ability to write to the files in the folder but keep everyone else from modifying them.

like image 79
Ryan Ahearn Avatar answered Sep 21 '22 12:09

Ryan Ahearn