The first case is a production server, the second is for development.

    2 answers 2

    On the production and on the development server should be all the same (IMHO). Optimally, 755 for folders and 644 for files - moreover, a user: the user, under which the Apache rotates, is www or www-data usually.

    • one
      if the www-data is, and I work under a different <username>, then how can I edit files during development? - Sergey
    • Under sudo. sudo -u www-data bash, and you're under the user www-data. Then edit / merge what you want. How to set up the ship - look. And of course it is better to develop on a local computer, where OpenServer stands for example, upload everything into git-turnips, and on the server into one command git pull (run under sudo) upload the whole project at once. - Goncharov Alexander
    • and if the server is on the local machine? through sudo every time uncomfortable. - Sergey
    • I understand you will not rule from the console. Here I will not prompt, I'm sorry - I only use Windows for local machines with IDE. Although I will suppose that then without sudo, then it is necessary that the Apache is spinning under your user in the system, or so that you can log in under it - in general, that the one who writes the files and the one who is the Apache = the same user. - Goncharov Alexander

    Place the chmod 2775 directory and the chown .www-data group chown .www-data . Now new files in this directory will have a directory group ( more on the first digit of chmod ). Add yourself to the www-data group:

     sudo adduser $USER www-data. 

    Install umask 2 so that new files are automatically available to the group. Although now you can make files in this directory chmod 664 yourself without privileges.

    In order for a new group membership to take effect, you must log in again.