1

For my own reference.

I'm having trouble finding the correct permissions for running a web site on my ubuntu machine. I'm confused whether to put 777/755 to whole directory of my site or webroot public_html in my home folder.

my username is arehman and my webserver user is www-data

OS: Ubuntu 16.04 LTS 64-bit Apache2 php 7.1

EDIT

I have symlink to /var/html/www/project_1 and the project is in home/user/public_html/project_1. I have given 775 to the project/uploads folder and now files gets uploaded; but now every file is owned by www-data user:group and I can't edit the files if needed. Only way is to copy them, edit, and paste back in uploads folder.

Is there a way to make uploaded files have write access for my user?

1
  • Since it is a website I feel 755 is enough.777 means you are giving read, write and execute permission for user,group and others. For a website I feel only the user require all three permission so giving 755 is enough.
    – Sneha
    Mar 2, 2017 at 12:56

1 Answer 1

0

Basically, the 777 or 755 is broken down like this:

Each of the numbers represents the privileges that are given to a particular group of people. The first number represents the privileges given to user (system user), the second represents privileges given to group (system group), and the third is for others (anyone else trying to access the file).

Breaking down into the individual number, each value begins at 0 (no privileges) and adds 4 for executing privileges, 2 for writing privileges, and 1 for reading privileges. Thus, 7 means executing, writing, and reading privileges (4 + 2 + 1), while 5 means executing and reading privileges (4 + 1).

For a website, the system user must have all write privileges (along with read and execute), hence the first number must be a 7. For group and others, only reading and executing privileges is necessary, hence the second and third numbers should be 5, yielding 755 as the correct privileges for your public_html folder.

1
  • Thanks for answer. I have edited my question please guide a bit more. Mar 2, 2017 at 14:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .