1

I just installed lamp-server^ and wanted to try it I created a php file but I was not able to move it to /var/www because owner of that folder is root I managed it using terminal (I logged in as root). But I dont want to do it everytime. Is there any other way to do it? I dont want to use terminal every time I want to try to access that folder.

Tim
  • 32,861
  • 27
  • 118
  • 178
Kdaydin
  • 111
  • Im not just interested in that specific folder. Any folders with root owner. I want to know what to do If it happens again with another folder. – Kdaydin Jun 07 '15 at 17:06
  • same applies, just use different group. what other folder are you thinking of? – Tim Jun 07 '15 at 17:07
  • @L0RDQB you just use sudo cp foo bar to copy foo to bar. – terdon Jun 07 '15 at 17:07
  • @L0RDQB any root folders (other than /var/www) you should use sudo cp to copy. The permissions of them shouldn't be changed (/var/www is an exception). – Tim Jun 07 '15 at 17:08
  • is there any other way like giving root access to my current user ? – Kdaydin Jun 07 '15 at 17:09
  • I created a symlink to a folder on my desktop for easy access! – Alvar Jun 07 '15 at 17:09
  • @L0RDQB yes I have a symlink too to a folder called Website for me :) – Tim Jun 07 '15 at 17:16

1 Answers1

0

I don't know how it is done in LAMP, but a pure Apache setup has a user group called www-data with write permission into /var/www.

To achieve the same result, follow these steps:

  1. Create the group www-data, if not already existent (check with grep www-data /etc/group):

    groupadd www-data

  2. Transfer group ownership of /var/www to www-data, if not already done:

    sudo chgrp www-data /var/www
    
  3. Add your user to the www-data group:

    sudo usermod -a -G www-data <username>
    
  4. Fix permissions, if necessary (give full permission to group members):

    sudo chmod g+rwx /var/www
    

Now you can access the directory without sudoing.

s3lph
  • 14,314
  • 11
  • 59
  • 82