Jump to content

Absoloute beginner has problems modifying files in Ubuntu(d) LAMP


Recommended Posts

Theres a few things I do to make administering websites on Debian easier, rather then needing to sudo all the time.

 

The first is to create a new group www, join that group, then give that group permissions to write to the /var/www directory.

 

sudo addgroup www
sudo gpasswd -a yourusername www

 

You can also make yourself an administer of the www group, this will allow you to add and remove users from the group.

sudo gpasswd -A yourusername

 

From there all you really need do is set the permissions properly on the /var/www directory and its conents.

sudo chmod ugo-wrx /var/www
sudo chmod u+wrx,g+wrxs,o+rx /var/www
find /var/www -type f sudo chmod u+rw,g+rw,o+r {} \;
find /var/www -type d sudo chmod u+rwx,g+rwx,o+rx {} \;

 

You should now be able to freely write / read from within the /var/www directory and any files you create will belong to you and the www group.

 

Theres more you can do including creating a similar policy for the /etc/apache2/sites-* directories. Hopefully this small example will give you the idea.

Theres a few things I do to make administering websites on Debian easier, rather then needing to sudo all the time.

 

The first is to create a new group www, join that group, then give that group permissions to write to the /var/www directory.

 

sudo addgroup www
sudo gpasswd -a yourusername www

 

You can also make yourself an administer of the www group, this will allow you to add and remove users from the group.

sudo gpasswd -A yourusername

 

From there all you really need do is set the permissions properly on the /var/www directory and its conents.

sudo chmod ugo-wrx /var/www
sudo chmod u+wrx,g+wrxs,o+rx /var/www
find /var/www -type f sudo chmod u+rw,g+rw,o+r {} \;
find /var/www -type d sudo chmod u+rwx,g+rwx,o+rx {} \;

 

You should now be able to freely write / read from within the /var/www directory and any files you create will belong to you and the www group.

 

Theres more you can do including creating a similar policy for the /etc/apache2/sites-* directories. Hopefully this small example will give you the idea.

 

Geesh, I always have silly problems like this when using Linux.

 

Gonna give it a try now, but I really don't like using the terminal all the time :)

 

Q: In "sudo gpasswd -a yourusername www", should "gpasswd" be replaced by my password?

 

Thanks :D

 

D

What's the default-site directory's full path?

 

I think it's "/var/www/"

 

Maybe an easier solution to all this is to change the path to my site to a directory I already have full rights to? Or would that mean other problems later when trying to run a script?

 

Thanks for all your help :D

 

D

Q: In "sudo gpasswd -a yourusername www", should "gpasswd" be replaced by my password?

 

No, gpasswd is a command, used to add users to groups.

 

That line will add you to the www group.

 

Also, I just realised. These lines....

 

find /var/www -type f sudo chmod u+rw,g+rw,o+r {} \;
find /var/www -type d sudo chmod u+rwx,g+rwx,o+rx {} \;

 

Should be....

 

find /var/www -type f -exec sudo chmod u+rw,g+rw,o+r {} \;
find /var/www -type d -exec sudo chmod u+rwx,g+rwx,o+rx {} \;
find /var/www -type f -exec sudo chown :www {} \;
find /var/www -type d -exec sudo chown :www {} \;

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.