Php apache permissions - best practices

I have a codeigniter application that creates folders using php. The owner of any folders created using php is "apache", however, if I want to upload a folder via ftp, then my ftp username will be the owner.

I had a problem with php (apache) being unable to modify the file inside the folder downloaded via ftp due to permissions. In the meantime, I added my ftpuser to the apache group and apache to the ftpuser group, but wondered if there is a better way?

+3
source share
2 answers

Actually, what I'm doing is chgrp, any php directory will write to the apache group, it works like (www on my server, maybe apache on yours), chmod g + s. This will make any file created in this directory also belong to the web server group. If umask allows you to record a group by default, this will solve your problem.

+3
source

Best practice is only to allow users to read / write the files they need.

In my web applications, I have a data directory for a website that stores all my dynamically generated data from the application.

Then I give permission for the application to write to this directory, and nothing more.

+1
source

All Articles