I installed a local web-server (apache2, php5, mysql). All the time I want to edit some permissions or to create a folder or to add some lines to hosts I need to login as a root.

Do I need to grant privileges by the root all the time for this folders and files or is there a way to make it at once? Maybe i should reinstall webserver by the user i want to use one?


You can do it by giving the file ownership to the user. Use chown command to do that.

ex: chown -R user website_folder

[-R is for recursively change file ownership; change user and the folder accordingly].

And make sure you have write permission too. You can set write permission with chmod.

ex: chmod +x webpage.html

[The above command will give the write permission to the current user]

  • This means i have to do it every time i want to create a project.. Or if i change user to basic webserver folders i would not have to change it after? – Rootical V. Jun 1 '12 at 13:43
  • No, you can do chown -R user /var/www. it will change all permission. But don't change permissions of /etc/php5 (or any file in /etc/ ;). It is not a good practice. – Manula Waidyanatha Jun 1 '12 at 13:47

Another option is add the user to the group used by the web server (and the group of the web files)

usermod -aG www-apache $USER

normally, the apache config files are write privileges to www-apache group (and the dir in /var/www)

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.