0

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?

2 Answers 2

0

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]

2
  • 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? Jun 1, 2012 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. Jun 1, 2012 at 13:47
0

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)

You must log in to answer this question.

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